Browse Source

Improved command highlighting.

master
chrisgregan 11 years ago
parent
commit
3117961982
  1. 34
      Assets/Fungus/Editor/FungusEditorWindow.cs
  2. 22
      Assets/Fungus/Editor/SequenceControllerEditor.cs
  3. 8
      Assets/Fungus/Editor/SequenceControllerEditor.cs.meta
  4. BIN
      Assets/Fungus/Tests/Sequence/SequenceTest.unity
  5. 2
      Assets/Fungus/Tests/Sequence/SequenceTestRoom.cs
  6. 1
      Assets/Fungus/VisualScripting/Sequence.cs
  7. 16
      Assets/Fungus/VisualScripting/SequenceController.cs

34
Assets/Fungus/Editor/FungusEditorWindow.cs

@ -59,6 +59,25 @@ public class FungusEditorWindow : EditorWindow
return;
}
string labelText = sequenceController.name;
if (Application.isPlaying)
{
if (sequenceController.activeSequence == null)
{
labelText += ": Idle";
}
else
{
labelText += ": Active";
}
}
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.Label(labelText);
GUILayout.Space(30);
GUILayout.EndHorizontal();
// BeginScrollView lets you specify a region that 'looks into' a much larger area. In this case, we create a canvas
// 1000px X 1000px in size that's constrained to the same region as the EditorWindow. If the scrollbars are modified,
// the new values are stored in the Vector2 that's returned.
@ -145,7 +164,7 @@ public class FungusEditorWindow : EditorWindow
{
GUI.backgroundColor = Color.red;
}
else if (command.IsExecuting())
else if (ShouldHighlight(command))
{
GUI.backgroundColor = Color.yellow;
}
@ -172,10 +191,10 @@ public class FungusEditorWindow : EditorWindow
FungusCommand[] commands = sequence.GetComponentsInChildren<FungusCommand>();
foreach (FungusCommand command in commands)
{
bool isExecuting = command.IsExecuting();
bool highlight = ShouldHighlight(command);
if (highlightedOnly && !isExecuting ||
!highlightedOnly && isExecuting)
if (highlightedOnly && !highlight ||
!highlightedOnly && highlight)
{
continue;
}
@ -202,7 +221,7 @@ public class FungusEditorWindow : EditorWindow
pointB = p2;
Color color = Color.grey;
if (command.IsExecuting())
if (highlight)
{
color = Color.yellow;
}
@ -211,4 +230,9 @@ public class FungusEditorWindow : EditorWindow
}
}
}
bool ShouldHighlight(FungusCommand command)
{
return (command.IsExecuting() || (FungusCommandEditor.selectedCommand == command));
}
}

22
Assets/Fungus/Editor/SequenceControllerEditor.cs

@ -0,0 +1,22 @@
using UnityEditor;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Fungus;
[CustomEditor (typeof(SequenceController))]
public class SequenceControllerEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Open Fungus Editor"))
{
EditorWindow.GetWindow(typeof(FungusEditorWindow), false, "Fungus Editor");
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
}

8
Assets/Fungus/Editor/SequenceControllerEditor.cs.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0444d16cc20de47878a9b392aea6a4a2
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

BIN
Assets/Fungus/Tests/Sequence/SequenceTest.unity

Binary file not shown.

2
Assets/Fungus/Tests/Sequence/SequenceTestRoom.cs

@ -8,7 +8,7 @@ public class SequenceTestRoom : Room
void OnEnter()
{
sequenceController.ExecuteSequence(sequenceController.activeSequence);
sequenceController.Execute();
/*
Sequence s = GetComponent<Sequence>();

1
Assets/Fungus/VisualScripting/Sequence.cs

@ -110,6 +110,7 @@ namespace Fungus
public void Finish()
{
activeCommand = null;
sequenceController.activeSequence = null;
// No more commands to run in current sequence
#if UNITY_EDITOR

16
Assets/Fungus/VisualScripting/SequenceController.cs

@ -2,6 +2,7 @@
using UnityEditor;
#endif
using UnityEngine;
using System;
using System.Collections;
using Fungus;
@ -9,11 +10,24 @@ public class SequenceController : MonoBehaviour
{
public float stepTime;
public Sequence startSequence;
[System.NonSerialized]
public Sequence activeSequence;
public void Execute()
{
if (startSequence == null)
{
return;
}
ExecuteSequence(startSequence);
}
public void ExecuteSequence(Sequence sequence)
{
if (activeSequence == null)
if (sequence == null)
{
return;
}

Loading…
Cancel
Save