Browse Source

Reverted sequence to use game object name. Added Fungus Script menu item

master
chrisgregan 10 years ago
parent
commit
618d34c91c
  1. BIN
      Assets/Example/Scenes/Example.unity
  2. 18
      Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs
  3. 14
      Assets/Fungus/FungusScript/Editor/SequenceEditor.cs
  4. 2
      Assets/Fungus/FungusScript/Scripts/Sequence.cs

BIN
Assets/Example/Scenes/Example.unity

Binary file not shown.

18
Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs

@ -24,6 +24,20 @@ 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;
}
// 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
void ShowButton(Rect position) {
@ -138,7 +152,7 @@ namespace Fungus
{
Sequence sequence = sequences[i];
float titleWidth = windowStyle.CalcSize(new GUIContent(sequence.sequenceName)).x;
float titleWidth = windowStyle.CalcSize(new GUIContent(sequence.name)).x;
float windowWidth = Mathf.Max (titleWidth + 10, 100);
if (fungusScript.selectedSequence == sequence ||
@ -310,7 +324,7 @@ namespace Fungus
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
GUILayout.Label(sequence.sequenceName, labelStyle);
GUILayout.Label(sequence.name, labelStyle);
GUILayout.FlexibleSpace();
GUILayout.EndVertical();

14
Assets/Fungus/FungusScript/Editor/SequenceEditor.cs

@ -17,7 +17,6 @@ namespace Fungus
void OnEnable()
{
sequenceNameProp = serializedObject.FindProperty("sequenceName");
descriptionProp = serializedObject.FindProperty("description");
}
@ -32,7 +31,14 @@ namespace Fungus
Sequence sequence = fungusScript.selectedSequence;
EditorGUILayout.PropertyField(sequenceNameProp);
EditorGUI.BeginChangeCheck();
string sequenceName = EditorGUILayout.TextField(new GUIContent("Name", "Name of sequence object"), sequence.gameObject.name);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sequence.gameObject, "Set Sequence Name");
sequence.gameObject.name = sequenceName;
}
EditorGUILayout.PropertyField(descriptionProp);
EditorGUILayout.Separator();
@ -183,7 +189,7 @@ namespace Fungus
Sequence[] sequences = fungusScript.GetComponentsInChildren<Sequence>();
for (int i = 0; i < sequences.Length; ++i)
{
sequenceNames.Add(new GUIContent(sequences[i].sequenceName));
sequenceNames.Add(new GUIContent(sequences[i].name));
if (sequence == sequences[i])
{
@ -221,7 +227,7 @@ namespace Fungus
Sequence[] sequences = fungusScript.GetComponentsInChildren<Sequence>();
for (int i = 0; i < sequences.Length; ++i)
{
sequenceNames.Add(new GUIContent(sequences[i].sequenceName));
sequenceNames.Add(new GUIContent(sequences[i].name));
if (sequence == sequences[i])
{

2
Assets/Fungus/FungusScript/Scripts/Sequence.cs

@ -14,8 +14,6 @@ namespace Fungus
{
public Rect nodeRect = new Rect(10, 10, 100, 40);
public string sequenceName = "Sequence";
public string description = "";
[System.NonSerialized]

Loading…
Cancel
Save