From e346683e2084217879329f3aff1d7991b1269fc0 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Mon, 18 Aug 2014 11:40:01 +0100 Subject: [PATCH] Fixed null reference errors --- .../FungusScript/FungusCommandEditor.cs | 96 ++++++++---------- Assets/Fungus/VisualScripting/Call.cs | 5 + Assets/Shuttle/ShuttleGame.unity | Bin 81780 -> 81980 bytes 3 files changed, 50 insertions(+), 51 deletions(-) diff --git a/Assets/Fungus/Editor/FungusScript/FungusCommandEditor.cs b/Assets/Fungus/Editor/FungusScript/FungusCommandEditor.cs index 6baab06f..5e7451c2 100644 --- a/Assets/Fungus/Editor/FungusScript/FungusCommandEditor.cs +++ b/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(fungusScript.copyCommand, t.gameObject); + fungusScript.copyCommand = t; + } + + if (fungusScript.copyCommand != null) + { + if (GUILayout.Button("Paste", EditorStyles.miniButtonMid)) + { + CopyComponent(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); + } } } diff --git a/Assets/Fungus/VisualScripting/Call.cs b/Assets/Fungus/VisualScripting/Call.cs index 4d522945..fb2866ff 100644 --- a/Assets/Fungus/VisualScripting/Call.cs +++ b/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 diff --git a/Assets/Shuttle/ShuttleGame.unity b/Assets/Shuttle/ShuttleGame.unity index 892b851ad30534d7dd1e5646667e8753cb581d98..60506a40fbd5136384168bc167b9bbe44742b282 100644 GIT binary patch delta 657 zcmZ9~F-RL>6bJD4?44E+njwRrh%q5LnB+o5tys8-i0G2RsUTbxG10U%;t)hgmTV3w z89uvpu$x0dDAyrFI#ibyZm9@eM6J>x5j z#Of#!wPLO19p5f^v9NcsD8KY2X2O+TqH#RDtX8WlxcXsgACYRa04(*NDcQB_qvQu< zu@#4|@~e`cNW=Y=^|m8ecYtUHW?FU(OIRksYw;Uqz%;BIwI?t|A=-l7S+!-@{-Y)9 zTRsD(fGy0{((JofRtedafFgAUO=R*!NJti~{E3D}6 zJ^YKswwJfKNw_@h7BMe(a4`GTbc&B%Ea{P6?v%Mjr2Bcgwf0BUjJ`u@1S7pRI6iXSOHkJ_Nez>omse}kI#7$_#7 z&%h7@6#EAidjb^8fQqpI#X3s$iQ!rp)SOOIL3)TA)D0TuURsj_I z^Z$Q6*vX7n84?`~85nYy7#LnMLvX6sgyapz3=AAdVwo=-3U`ZP=)a}