Browse Source

Fixed null reference errors

master
chrisgregan 11 years ago
parent
commit
e346683e20
  1. 94
      Assets/Fungus/Editor/FungusScript/FungusCommandEditor.cs
  2. 5
      Assets/Fungus/VisualScripting/Call.cs
  3. BIN
      Assets/Shuttle/ShuttleGame.unity

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

@ -25,6 +25,11 @@ namespace Fungus.Script
{ {
FungusCommand t = target as FungusCommand; FungusCommand t = target as FungusCommand;
if (t == null)
{
return;
}
GUILayout.BeginVertical(); GUILayout.BeginVertical();
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
@ -44,74 +49,63 @@ namespace Fungus.Script
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
if (!t.expanded) if (t.expanded)
{
GUILayout.EndVertical();
if (Event.current.type == EventType.Repaint &&
t.IsExecuting())
{
Rect rect = GUILayoutUtility.GetLastRect();
rect.x -= 10;
rect.width += 10;
GLDraw.DrawBox(rect, Color.green, 1.5f);
}
return;
}
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Up", EditorStyles.miniButtonLeft))
{ {
UnityEditorInternal.ComponentUtility.MoveComponentUp(t); GUILayout.BeginHorizontal();
}
if (GUILayout.Button("Down", EditorStyles.miniButtonMid))
{
UnityEditorInternal.ComponentUtility.MoveComponentDown(t);
}
FungusScript fungusScript = t.GetFungusScript(); GUILayout.FlexibleSpace();
if (fungusScript != null) if (GUILayout.Button("Up", EditorStyles.miniButtonLeft))
{
if (GUILayout.Button("Copy", EditorStyles.miniButtonMid))
{ {
fungusScript.copyCommand = t; UnityEditorInternal.ComponentUtility.MoveComponentUp(t);
} }
if (GUILayout.Button("Down", EditorStyles.miniButtonMid))
{
UnityEditorInternal.ComponentUtility.MoveComponentDown(t);
}
FungusScript fungusScript = t.GetFungusScript();
if (fungusScript.copyCommand != null) if (fungusScript != null)
{ {
if (GUILayout.Button("Paste", EditorStyles.miniButtonMid)) if (GUILayout.Button("Copy", EditorStyles.miniButtonMid))
{ {
CopyComponent<FungusCommand>(fungusScript.copyCommand, t.gameObject); fungusScript.copyCommand = t;
}
if (fungusScript.copyCommand != null)
{
if (GUILayout.Button("Paste", EditorStyles.miniButtonMid))
{
CopyComponent<FungusCommand>(fungusScript.copyCommand, t.gameObject);
}
} }
} }
}
if (GUILayout.Button("Delete", EditorStyles.miniButtonRight)) if (GUILayout.Button("Delete", EditorStyles.miniButtonRight))
{ {
Undo.DestroyObjectImmediate(t); Undo.DestroyObjectImmediate(t);
return; return;
} }
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
EditorGUILayout.Separator(); EditorGUILayout.Separator();
DrawCommandGUI(); DrawCommandGUI();
EditorGUILayout.Separator(); EditorGUILayout.Separator();
if (t != null) if (t != null)
{
if (t.errorMessage.Length > 0)
{ {
GUIStyle style = new GUIStyle(GUI.skin.label); if (t.errorMessage.Length > 0)
style.normal.textColor = new Color(1,0,0); {
EditorGUILayout.LabelField(new GUIContent("Error: " + t.errorMessage), style); GUIStyle style = new GUIStyle(GUI.skin.label);
style.normal.textColor = new Color(1,0,0);
EditorGUILayout.LabelField(new GUIContent("Error: " + t.errorMessage), style);
}
} }
} }

5
Assets/Fungus/VisualScripting/Call.cs

@ -190,6 +190,11 @@ namespace Fungus.Script
{ {
if (callCondition == CallCondition.CallAlways) if (callCondition == CallCondition.CallAlways)
{ {
if (targetSequence == null)
{
return "No target sequence selected";
}
return targetSequence.name; return targetSequence.name;
} }
else else

BIN
Assets/Shuttle/ShuttleGame.unity

Binary file not shown.
Loading…
Cancel
Save