From 8a7a1a2ffa075d3ed550995d569a24143659950a Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Fri, 19 Sep 2014 16:48:04 +0100 Subject: [PATCH] Added GameObject menu items for Dialog prefabs --- .../Fungus/Dialog/Editor/DialogMenuItems.cs | 53 +++++++++++++++++++ .../Dialog/Editor/DialogMenuItems.cs.meta | 8 +++ .../Editor/FungusScriptMenuItems.cs | 27 ++++++++++ .../Editor/FungusScriptMenuItems.cs.meta | 8 +++ .../FungusScript/Editor/FungusScriptWindow.cs | 16 ------ 5 files changed, 96 insertions(+), 16 deletions(-) create mode 100644 Assets/Fungus/Dialog/Editor/DialogMenuItems.cs create mode 100644 Assets/Fungus/Dialog/Editor/DialogMenuItems.cs.meta create mode 100644 Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs create mode 100644 Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs.meta diff --git a/Assets/Fungus/Dialog/Editor/DialogMenuItems.cs b/Assets/Fungus/Dialog/Editor/DialogMenuItems.cs new file mode 100644 index 00000000..1db612fe --- /dev/null +++ b/Assets/Fungus/Dialog/Editor/DialogMenuItems.cs @@ -0,0 +1,53 @@ +using UnityEngine; +using UnityEditor; +using System.Collections; + +namespace Fungus +{ + + public class DialogMenuItems + { + + [MenuItem("GameObject/Fungus/Dialog/Background")] + static void CreateBackground() + { + InstantiatePrefab("Background"); + } + + [MenuItem("GameObject/Fungus/Dialog/Character")] + static void CreateCharacter() + { + InstantiatePrefab("Character"); + } + + [MenuItem("GameObject/Fungus/Dialog/NarratorDialog")] + static void CreateNarratorDialog() + { + InstantiatePrefab("NarratorDialog"); + } + + [MenuItem("GameObject/Fungus/Dialog/SayDialog")] + static void CreateSayDialog() + { + InstantiatePrefab("SayDialog"); + } + + [MenuItem("GameObject/Fungus/Dialog/ChooseDialog")] + static void CreateChooseDialog() + { + InstantiatePrefab("ChooseDialog"); + } + + static void InstantiatePrefab(string prefabName) + { + GameObject prefab = Resources.LoadAssetAtPath("Assets/Fungus/Dialog/Prefabs/" + prefabName + ".prefab", typeof(GameObject)) as GameObject; + if (prefab != null) + { + GameObject go = GameObject.Instantiate(prefab) as GameObject; + go.name = prefabName; + } + } + + } + +} \ No newline at end of file diff --git a/Assets/Fungus/Dialog/Editor/DialogMenuItems.cs.meta b/Assets/Fungus/Dialog/Editor/DialogMenuItems.cs.meta new file mode 100644 index 00000000..d5dd0cc2 --- /dev/null +++ b/Assets/Fungus/Dialog/Editor/DialogMenuItems.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ce2477bdc80e3464dae8a07bf263f571 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs b/Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs new file mode 100644 index 00000000..78cfced9 --- /dev/null +++ b/Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs @@ -0,0 +1,27 @@ +using UnityEngine; +using UnityEditor; +using System.Collections; + +namespace Fungus +{ + + public class FungusScriptMenuItems + { + [MenuItem("GameObject/Fungus/Fungus Script")] + static void CreateFungusScript() + { + GameObject newFungusScriptGO = new GameObject(); + newFungusScriptGO.name = "FungusScript"; + FungusScript fungusScript = newFungusScriptGO.AddComponent(); + GameObject newSequenceGO = new GameObject(); + newSequenceGO.transform.parent = newFungusScriptGO.transform; + newSequenceGO.name = "Start"; + newSequenceGO.hideFlags = HideFlags.HideInHierarchy; + Sequence sequence = newSequenceGO.AddComponent(); + fungusScript.startSequence = sequence; + fungusScript.selectedSequence = sequence; + Undo.RegisterCreatedObjectUndo(newFungusScriptGO, "Create Fungus Script"); + } + } + +} \ No newline at end of file diff --git a/Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs.meta b/Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs.meta new file mode 100644 index 00000000..ab56bf69 --- /dev/null +++ b/Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e2db84d6dd8cb4ba390719566768a071 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs b/Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs index 64fe612c..6da5f443 100755 --- a/Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs +++ b/Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs @@ -24,22 +24,6 @@ namespace Fungus GetWindow(typeof(FungusScriptWindow), false, "Fungus Script"); } - [MenuItem("GameObject/Fungus/Fungus Script")] - static void CreateFungusScript() - { - GameObject newFungusScriptGO = new GameObject(); - newFungusScriptGO.name = "FungusScript"; - FungusScript fungusScript = newFungusScriptGO.AddComponent(); - GameObject newSequenceGO = new GameObject(); - newSequenceGO.transform.parent = newFungusScriptGO.transform; - newSequenceGO.name = "Start"; - newSequenceGO.hideFlags = HideFlags.HideInHierarchy; - Sequence sequence = newSequenceGO.AddComponent(); - fungusScript.startSequence = sequence; - fungusScript.selectedSequence = sequence; - Undo.RegisterCreatedObjectUndo(newFungusScriptGO, "Create Fungus Script"); - } - // Implementing this method causes the padlock image to display on the window // https://leahayes.wordpress.com/2013/04/30/adding-the-little-padlock-button-to-your-editorwindow/#more-455 protected virtual void ShowButton(Rect position) {