You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.6 KiB
62 lines
1.6 KiB
11 years ago
|
using UnityEngine;
|
||
11 years ago
|
using UnityEditor;
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
|
namespace Fungus.Script
|
||
|
{
|
||
|
|
||
|
public class VariablesWindow : EditorWindow
|
||
|
{
|
||
|
Vector2 scrollPos = new Vector2();
|
||
|
|
||
|
public void OnInspectorUpdate()
|
||
|
{
|
||
|
Repaint();
|
||
|
}
|
||
|
|
||
|
void OnGUI()
|
||
|
{
|
||
11 years ago
|
FungusScript fungusScript = FungusScriptWindow.GetFungusScript();
|
||
11 years ago
|
|
||
|
if (fungusScript == null)
|
||
|
{
|
||
|
GUILayout.Label("No Fungus Script object selected");
|
||
|
return;
|
||
|
}
|
||
|
|
||
11 years ago
|
// Warn about conflicting global variable types
|
||
11 years ago
|
Dictionary<string, FungusVariable> globals = new Dictionary<string, FungusVariable>();
|
||
11 years ago
|
FungusScript[] fungusScripts = GameObject.FindObjectsOfType<FungusScript>();
|
||
|
foreach (FungusScript fs in fungusScripts)
|
||
|
{
|
||
11 years ago
|
FungusVariable[] variables = fs.GetComponents<FungusVariable>();
|
||
|
foreach (FungusVariable v in variables)
|
||
11 years ago
|
{
|
||
|
if (v.scope == VariableScope.Global)
|
||
|
{
|
||
11 years ago
|
if (globals.ContainsKey(v.key))
|
||
11 years ago
|
{
|
||
11 years ago
|
if (globals[v.key].GetType() != v.GetType())
|
||
11 years ago
|
{
|
||
|
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);
|
||
|
}
|
||
|
}
|
||
11 years ago
|
globals[v.key] = v;
|
||
11 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
11 years ago
|
scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.MinWidth(Mathf.Max(position.width, 300)));
|
||
|
|
||
11 years ago
|
FungusScriptEditor fungusScriptEditor = Editor.CreateEditor(fungusScript) as FungusScriptEditor;
|
||
|
fungusScriptEditor.DrawVariablesGUI();
|
||
|
|
||
11 years ago
|
GUILayout.EndScrollView();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|