From 45293c5d47003727c78f1605bef8344a0b3019d5 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Wed, 25 Feb 2015 13:56:22 +0000 Subject: [PATCH] Added checks for Null variables in list #84 --- .../Fungus/FungusScript/Editor/VariableEditor.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Assets/Fungus/FungusScript/Editor/VariableEditor.cs b/Assets/Fungus/FungusScript/Editor/VariableEditor.cs index 645a5cf7..7f7e2d4b 100644 --- a/Assets/Fungus/FungusScript/Editor/VariableEditor.cs +++ b/Assets/Fungus/FungusScript/Editor/VariableEditor.cs @@ -114,16 +114,26 @@ namespace Fungus public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) { VariablePropertyAttribute variableProperty = attribute as VariablePropertyAttribute; + if (variableProperty == null) + { + return; + } EditorGUI.BeginProperty(position, label, property); // Filter the variables by the types listed in the VariableProperty attribute Func compare = v => { + if (v == null) + { + return false; + } + if (variableProperty.VariableTypes.Length == 0) { return true; } + return variableProperty.VariableTypes.Contains(v.GetType()); }; @@ -201,6 +211,11 @@ namespace Fungus int selectedIndex = 0; foreach (Variable v in fungusScript.variables) { + if (v == null) + { + continue; + } + if (v.GetType() != typeof(T)) { continue;