From 8fcc825cf51524cd6c3feffee351a7d25cbe2504 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Thu, 7 Aug 2014 11:59:38 +0100 Subject: [PATCH] Added warning about conflicting global variable types --- .../Editor/FungusScript/VariablesWindow.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Assets/Fungus/Editor/FungusScript/VariablesWindow.cs b/Assets/Fungus/Editor/FungusScript/VariablesWindow.cs index e25b5bd2..3177a839 100644 --- a/Assets/Fungus/Editor/FungusScript/VariablesWindow.cs +++ b/Assets/Fungus/Editor/FungusScript/VariablesWindow.cs @@ -26,6 +26,29 @@ namespace Fungus.Script return; } + // Warn about conflicting global variable types + Dictionary globalTypes = new Dictionary(); + FungusScript[] fungusScripts = GameObject.FindObjectsOfType(); + foreach (FungusScript fs in fungusScripts) + { + foreach (Variable v in fs.variables) + { + if (v.scope == VariableScope.Global) + { + if (globalTypes.ContainsKey(v.key)) + { + if (globalTypes[v.key] != v.type) + { + GUIStyle errorStyle = new GUIStyle(GUI.skin.label); + errorStyle.normal.textColor = new Color(1,0,0); + GUILayout.Label("Error: Global '" + v.key + "' must use the same type in all scripts.", errorStyle); + } + } + globalTypes[v.key] = v.type; + } + } + } + bool showValues = Application.isPlaying; float columnWidth = (position.width - 40) / (showValues ? 4 : 3);