Browse Source

Improved button layout, using foldout

master
chrisgregan 11 years ago
parent
commit
c26e81a40c
  1. 2
      Assets/Fungus/Editor/FungusScript/AddOptionEditor.cs
  2. 2
      Assets/Fungus/Editor/FungusScript/CallEditor.cs
  3. 48
      Assets/Fungus/Editor/FungusScript/FungusCommandEditor.cs
  4. 25
      Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs
  5. 21
      Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs
  6. 2
      Assets/Fungus/Editor/FungusScript/SayEditor.cs
  7. 2
      Assets/Fungus/Editor/FungusScript/SetEditor.cs
  8. 35
      Assets/Fungus/VisualScripting/Call.cs
  9. 4
      Assets/Fungus/VisualScripting/FungusCommand.cs
  10. 4
      Assets/Fungus/VisualScripting/FungusScript.cs
  11. 5
      Assets/Fungus/VisualScripting/Say.cs
  12. 5
      Assets/Fungus/VisualScripting/Sequence.cs
  13. BIN
      Assets/Shuttle/ShuttleGame.unity

2
Assets/Fungus/Editor/FungusScript/AddOptionEditor.cs

@ -10,7 +10,7 @@ namespace Fungus.Script
[CustomEditor (typeof(AddOption))] [CustomEditor (typeof(AddOption))]
public class AddOptionEditor : FungusCommandEditor public class AddOptionEditor : FungusCommandEditor
{ {
public override void DrawCommandInspectorGUI() public override void DrawCommandGUI()
{ {
AddOption t = target as AddOption; AddOption t = target as AddOption;

2
Assets/Fungus/Editor/FungusScript/CallEditor.cs

@ -9,7 +9,7 @@ namespace Fungus.Script
[CustomEditor (typeof(Call))] [CustomEditor (typeof(Call))]
public class CallEditor : FungusCommandEditor public class CallEditor : FungusCommandEditor
{ {
public override void DrawCommandInspectorGUI() public override void DrawCommandGUI()
{ {
serializedObject.Update(); serializedObject.Update();

48
Assets/Fungus/Editor/FungusScript/FungusCommandEditor.cs

@ -25,50 +25,66 @@ namespace Fungus.Script
{ {
FungusCommand t = target as FungusCommand; FungusCommand t = target as FungusCommand;
Rect rect = EditorGUILayout.BeginVertical(); GUILayout.BeginHorizontal();
t.expanded = EditorGUILayout.Foldout(t.expanded, t.GetType().Name);
GUIStyle labelStyle = EditorStyles.miniLabel;
GUILayout.Label(t.GetDescription().Replace("\n", "").Replace("\r", ""), labelStyle);
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
if (!t.expanded)
{
return;
}
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
if (GUILayout.Button("Up")) GUILayout.FlexibleSpace();
if (GUILayout.Button("Up", EditorStyles.miniButtonLeft))
{ {
UnityEditorInternal.ComponentUtility.MoveComponentUp(t); UnityEditorInternal.ComponentUtility.MoveComponentUp(t);
} }
if (GUILayout.Button("Down")) if (GUILayout.Button("Down", EditorStyles.miniButtonMid))
{ {
UnityEditorInternal.ComponentUtility.MoveComponentDown(t); UnityEditorInternal.ComponentUtility.MoveComponentDown(t);
} }
GUILayout.FlexibleSpace();
FungusScript fungusScript = t.GetFungusScript(); FungusScript fungusScript = t.GetFungusScript();
if (fungusScript != null) if (fungusScript != null)
{ {
if (GUILayout.Button("Copy")) if (GUILayout.Button("Copy", EditorStyles.miniButtonMid))
{ {
fungusScript.copyCommand = t; fungusScript.copyCommand = t;
} }
if (fungusScript.copyCommand != null) if (fungusScript.copyCommand != null)
{ {
if (GUILayout.Button("Paste")) if (GUILayout.Button("Paste", EditorStyles.miniButtonMid))
{ {
CopyComponent<FungusCommand>(fungusScript.copyCommand, t.gameObject); CopyComponent<FungusCommand>(fungusScript.copyCommand, t.gameObject);
} }
} }
} }
if (GUILayout.Button("Delete")) if (GUILayout.Button("Delete", EditorStyles.miniButtonRight))
{ {
Undo.DestroyObjectImmediate(t); Undo.DestroyObjectImmediate(t);
return; return;
} }
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
EditorGUILayout.Separator(); EditorGUILayout.Separator();
DrawCommandInspectorGUI(); DrawCommandGUI();
EditorGUILayout.Separator(); EditorGUILayout.Separator();
@ -81,6 +97,7 @@ namespace Fungus.Script
EditorGUILayout.LabelField(new GUIContent("Error: " + t.errorMessage), style); EditorGUILayout.LabelField(new GUIContent("Error: " + t.errorMessage), style);
} }
/*
if (t.IsExecuting()) if (t.IsExecuting())
{ {
EditorGUI.DrawRect(rect, new Color(0f, 1f, 0f, 0.25f)); EditorGUI.DrawRect(rect, new Color(0f, 1f, 0f, 0.25f));
@ -89,12 +106,11 @@ namespace Fungus.Script
{ {
EditorGUI.DrawRect(rect, new Color(1f, 1f, 0f, 0.25f)); EditorGUI.DrawRect(rect, new Color(1f, 1f, 0f, 0.25f));
} }
*/
} }
EditorGUILayout.EndVertical();
} }
public virtual void DrawCommandInspectorGUI() public virtual void DrawCommandGUI()
{ {
DrawDefaultInspector(); DrawDefaultInspector();
} }

25
Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs

@ -166,12 +166,7 @@ namespace Fungus.Script
GUILayout.BeginVertical(); GUILayout.BeginVertical();
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
GUILayout.Space(15); GUILayout.Space(10);
if (GUILayout.Button(labelText))
{
Selection.activeGameObject = fungusScript.gameObject;
}
GUI.backgroundColor = Color.white; GUI.backgroundColor = Color.white;
if (GUILayout.Button("Show Variables")) if (GUILayout.Button("Show Variables"))
{ {
@ -224,21 +219,9 @@ namespace Fungus.Script
Sequence sequence = windowSequenceMap[windowId]; Sequence sequence = windowSequenceMap[windowId];
if (!Application.isPlaying && sequence.gameObject == Selection.activeGameObject) GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
{ labelStyle.wordWrap = true;
string description = GUILayout.TextArea(sequence.description, GUILayout.ExpandWidth(true)); GUILayout.Label(sequence.description, labelStyle);
if (description != sequence.description)
{
Undo.RecordObject(sequence, "Set Description");
sequence.description = description;
}
}
else
{
GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
labelStyle.wordWrap = true;
GUILayout.Label(sequence.description, labelStyle);
}
/* /*
GUIStyle style = new GUIStyle(GUI.skin.button); GUIStyle style = new GUIStyle(GUI.skin.button);

21
Assets/Fungus/Editor/FungusScript/FungusScriptEditor.cs

@ -75,7 +75,8 @@ namespace Fungus.Script
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
} }
if (GUILayout.Button("Create")) if (GUILayout.Button("Create",
t.selectedSequence == null ? EditorStyles.miniButton : EditorStyles.miniButtonLeft))
{ {
GameObject go = new GameObject("Sequence"); GameObject go = new GameObject("Sequence");
go.transform.parent = t.transform; go.transform.parent = t.transform;
@ -96,12 +97,12 @@ namespace Fungus.Script
if (t.selectedSequence != null) if (t.selectedSequence != null)
{ {
if (GUILayout.Button("Delete")) if (GUILayout.Button("Delete", EditorStyles.miniButtonMid))
{ {
Undo.DestroyObjectImmediate(t.selectedSequence.gameObject); Undo.DestroyObjectImmediate(t.selectedSequence.gameObject);
t.selectedSequence = null; t.selectedSequence = null;
} }
if (GUILayout.Button("Duplicate")) if (GUILayout.Button("Duplicate", EditorStyles.miniButtonRight))
{ {
GameObject copy = GameObject.Instantiate(t.selectedSequence.gameObject) as GameObject; GameObject copy = GameObject.Instantiate(t.selectedSequence.gameObject) as GameObject;
copy.transform.parent = t.transform; copy.transform.parent = t.transform;
@ -149,20 +150,12 @@ namespace Fungus.Script
} }
EditorGUILayout.PrefixLabel("Commands"); EditorGUILayout.PrefixLabel("Commands");
FungusCommand[] commands = sequence.GetComponents<FungusCommand>(); FungusCommand[] commands = sequence.GetComponents<FungusCommand>();
foreach (FungusCommand command in commands) foreach (FungusCommand command in commands)
{ {
if (GUILayout.Button(command.GetCommandTitle(), GUILayout.ExpandWidth(true))) Editor commandEditor = Editor.CreateEditor(command);
{ commandEditor.OnInspectorGUI();
command.expanded = !command.expanded;
}
if (command.expanded)
{
Editor commandEditor = Editor.CreateEditor(command);
commandEditor.OnInspectorGUI();
}
} }
} }

2
Assets/Fungus/Editor/FungusScript/SayEditor.cs

@ -10,7 +10,7 @@ namespace Fungus.Script
[CustomEditor (typeof(Say))] [CustomEditor (typeof(Say))]
public class SayEditor : FungusCommandEditor public class SayEditor : FungusCommandEditor
{ {
public override void DrawCommandInspectorGUI() public override void DrawCommandGUI()
{ {
Say t = target as Say; Say t = target as Say;

2
Assets/Fungus/Editor/FungusScript/SetEditor.cs

@ -9,7 +9,7 @@ namespace Fungus.Script
[CustomEditor (typeof(Set))] [CustomEditor (typeof(Set))]
public class SetEditor : FungusCommandEditor public class SetEditor : FungusCommandEditor
{ {
public override void DrawCommandInspectorGUI() public override void DrawCommandGUI()
{ {
serializedObject.Update(); serializedObject.Update();

35
Assets/Fungus/VisualScripting/Call.cs

@ -185,14 +185,41 @@ namespace Fungus.Script
} }
} }
public override string GetCommandTitle() public override string GetDescription()
{ {
if (callCondition == CallCondition.CallAlways) if (callCondition == CallCondition.CallAlways)
{ {
return GetType().Name; return targetSequence.name;
}
else
{
if (variable == null)
{
return "No variable selected";
}
string description = "If " + variable.key + " then ";
if (onTrueSequence == null)
{
description += "<continue>";
}
else
{
description += onTrueSequence.name;
}
description += " else ";
if (onFalseSequence == null)
{
description += "<continue>";
}
else
{
description += onFalseSequence.name;
}
return description;
} }
return GetType().Name + "?";
} }
} }

4
Assets/Fungus/VisualScripting/FungusCommand.cs

@ -88,9 +88,9 @@ namespace Fungus.Script
public virtual void GetConnectedSequences(ref List<Sequence> connectedSequences) public virtual void GetConnectedSequences(ref List<Sequence> connectedSequences)
{} {}
public virtual string GetCommandTitle() public virtual string GetDescription()
{ {
return GetType().Name; return "";
} }
} }

4
Assets/Fungus/VisualScripting/FungusScript.cs

@ -52,10 +52,6 @@ namespace Fungus.Script
return; return;
} }
#if UNITY_EDITOR
Selection.activeGameObject = sequence.gameObject;
#endif
executingSequence = sequence; executingSequence = sequence;
sequence.ExecuteNextCommand(); sequence.ExecuteNextCommand();
} }

5
Assets/Fungus/VisualScripting/Say.cs

@ -82,6 +82,11 @@ namespace Fungus.Script
Continue(); Continue();
}); });
} }
public override string GetDescription()
{
return "\"" + text + "\"";
}
} }
} }

5
Assets/Fungus/VisualScripting/Sequence.cs

@ -131,11 +131,6 @@ namespace Fungus.Script
{ {
activeCommand = null; activeCommand = null;
fungusScript.executingSequence = null; fungusScript.executingSequence = null;
// No more commands to run in current sequence
#if UNITY_EDITOR
Selection.activeGameObject = fungusScript.gameObject;
#endif
} }
} }
} }

BIN
Assets/Shuttle/ShuttleGame.unity

Binary file not shown.
Loading…
Cancel
Save