Browse Source

Added GameObject menu items for Dialog prefabs

master
chrisgregan 10 years ago
parent
commit
8a7a1a2ffa
  1. 53
      Assets/Fungus/Dialog/Editor/DialogMenuItems.cs
  2. 8
      Assets/Fungus/Dialog/Editor/DialogMenuItems.cs.meta
  3. 27
      Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs
  4. 8
      Assets/Fungus/FungusScript/Editor/FungusScriptMenuItems.cs.meta
  5. 16
      Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs

53
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;
}
}
}
}

8
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:

27
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<FungusScript>();
GameObject newSequenceGO = new GameObject();
newSequenceGO.transform.parent = newFungusScriptGO.transform;
newSequenceGO.name = "Start";
newSequenceGO.hideFlags = HideFlags.HideInHierarchy;
Sequence sequence = newSequenceGO.AddComponent<Sequence>();
fungusScript.startSequence = sequence;
fungusScript.selectedSequence = sequence;
Undo.RegisterCreatedObjectUndo(newFungusScriptGO, "Create Fungus Script");
}
}
}

8
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:

16
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<FungusScript>();
GameObject newSequenceGO = new GameObject();
newSequenceGO.transform.parent = newFungusScriptGO.transform;
newSequenceGO.name = "Start";
newSequenceGO.hideFlags = HideFlags.HideInHierarchy;
Sequence sequence = newSequenceGO.AddComponent<Sequence>();
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) {

Loading…
Cancel
Save