Browse Source

Fixed null reference errors

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

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

@ -25,6 +25,11 @@ namespace Fungus.Script
{
FungusCommand t = target as FungusCommand;
if (t == null)
{
return;
}
GUILayout.BeginVertical();
GUILayout.BeginHorizontal();
@ -44,74 +49,63 @@ namespace Fungus.Script
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.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Up", EditorStyles.miniButtonLeft))
{
UnityEditorInternal.ComponentUtility.MoveComponentUp(t);
}
if (GUILayout.Button("Down", EditorStyles.miniButtonMid))
{
UnityEditorInternal.ComponentUtility.MoveComponentDown(t);
}
FungusScript fungusScript = t.GetFungusScript();
if (fungusScript != null)
{
if (GUILayout.Button("Copy", EditorStyles.miniButtonMid))
if (GUILayout.Button("Up", EditorStyles.miniButtonLeft))
{
UnityEditorInternal.ComponentUtility.MoveComponentUp(t);
}
if (GUILayout.Button("Down", EditorStyles.miniButtonMid))
{
fungusScript.copyCommand = t;
UnityEditorInternal.ComponentUtility.MoveComponentDown(t);
}
if (fungusScript.copyCommand != null)
FungusScript fungusScript = t.GetFungusScript();
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))
{
Undo.DestroyObjectImmediate(t);
return;
}
if (GUILayout.Button("Delete", EditorStyles.miniButtonRight))
{
Undo.DestroyObjectImmediate(t);
return;
}
GUILayout.FlexibleSpace();
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.EndHorizontal();
EditorGUILayout.Separator();
EditorGUILayout.Separator();
DrawCommandGUI();
DrawCommandGUI();
EditorGUILayout.Separator();
EditorGUILayout.Separator();
if (t != null)
{
if (t.errorMessage.Length > 0)
if (t != null)
{
GUIStyle style = new GUIStyle(GUI.skin.label);
style.normal.textColor = new Color(1,0,0);
EditorGUILayout.LabelField(new GUIContent("Error: " + t.errorMessage), style);
if (t.errorMessage.Length > 0)
{
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 (targetSequence == null)
{
return "No target sequence selected";
}
return targetSequence.name;
}
else

BIN
Assets/Shuttle/ShuttleGame.unity

Binary file not shown.
Loading…
Cancel
Save