7 changed files with 41 additions and 183 deletions
@ -1,71 +0,0 @@ |
|||||||
using UnityEngine; |
|
||||||
using UnityEditor; |
|
||||||
|
|
||||||
public class SplitViewWindow : EditorWindow |
|
||||||
{ |
|
||||||
private Vector2 scrollPos = Vector2.zero; |
|
||||||
float commandViewWidth; |
|
||||||
bool resize = false; |
|
||||||
Rect cursorChangeRect; |
|
||||||
|
|
||||||
public float minViewWidth = 150; |
|
||||||
|
|
||||||
[MenuItem("MyWindows/SplitView")] |
|
||||||
public static void Init(){ |
|
||||||
GetWindow<SplitViewWindow>(); |
|
||||||
} |
|
||||||
|
|
||||||
void OnEnable() |
|
||||||
{ |
|
||||||
commandViewWidth = minViewWidth; |
|
||||||
cursorChangeRect = new Rect(this.position.width - commandViewWidth, 0, 4f, this.position.height); |
|
||||||
} |
|
||||||
|
|
||||||
void OnGUI() |
|
||||||
{ |
|
||||||
GUILayout.BeginHorizontal(); |
|
||||||
DrawScriptView(); |
|
||||||
ResizeViews(); |
|
||||||
GUILayout.EndHorizontal(); |
|
||||||
|
|
||||||
Repaint(); |
|
||||||
} |
|
||||||
|
|
||||||
void DrawScriptView() |
|
||||||
{ |
|
||||||
Rect scriptViewRect = new Rect(0, 0, this.position.width - commandViewWidth, this.position.height); |
|
||||||
|
|
||||||
scrollPos = GUI.BeginScrollView(scriptViewRect, scrollPos, scriptViewRect); |
|
||||||
|
|
||||||
GUI.EndScrollView(); |
|
||||||
} |
|
||||||
|
|
||||||
void ResizeViews() |
|
||||||
{ |
|
||||||
cursorChangeRect.x = this.position.width - commandViewWidth; |
|
||||||
cursorChangeRect.height = this.position.height; |
|
||||||
|
|
||||||
GUI.color = Color.grey; |
|
||||||
GUI.DrawTexture(cursorChangeRect, EditorGUIUtility.whiteTexture); |
|
||||||
EditorGUIUtility.AddCursorRect(cursorChangeRect, MouseCursor.ResizeHorizontal); |
|
||||||
|
|
||||||
if (Event.current.type == EventType.mouseDown && cursorChangeRect.Contains(Event.current.mousePosition)) |
|
||||||
{ |
|
||||||
resize = true; |
|
||||||
} |
|
||||||
if (resize) |
|
||||||
{ |
|
||||||
commandViewWidth = this.position.width - Event.current.mousePosition.x; |
|
||||||
commandViewWidth = Mathf.Max(minViewWidth, commandViewWidth); |
|
||||||
commandViewWidth = Mathf.Min(this.position.width - minViewWidth, commandViewWidth); |
|
||||||
} |
|
||||||
if(Event.current.type == EventType.MouseUp) |
|
||||||
{ |
|
||||||
resize = false; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void DrawCommandView() |
|
||||||
{ |
|
||||||
} |
|
||||||
} |
|
@ -1,8 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 15f6cafd40d1c4995b33bc2e71625e7f |
|
||||||
MonoImporter: |
|
||||||
serializedVersion: 2 |
|
||||||
defaultReferences: [] |
|
||||||
executionOrder: 0 |
|
||||||
icon: {instanceID: 0} |
|
||||||
userData: |
|
@ -1,62 +0,0 @@ |
|||||||
using UnityEngine; |
|
||||||
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() |
|
||||||
{ |
|
||||||
FungusScript fungusScript = FungusScriptWindow.GetFungusScript(); |
|
||||||
|
|
||||||
if (fungusScript == null) |
|
||||||
{ |
|
||||||
GUILayout.Label("No Fungus Script object selected"); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
// Warn about conflicting global variable types |
|
||||||
Dictionary<string, FungusVariable> globals = new Dictionary<string, FungusVariable>(); |
|
||||||
FungusScript[] fungusScripts = GameObject.FindObjectsOfType<FungusScript>(); |
|
||||||
foreach (FungusScript fs in fungusScripts) |
|
||||||
{ |
|
||||||
FungusVariable[] variables = fs.GetComponents<FungusVariable>(); |
|
||||||
foreach (FungusVariable v in variables) |
|
||||||
{ |
|
||||||
if (v.scope == VariableScope.Global) |
|
||||||
{ |
|
||||||
if (globals.ContainsKey(v.key)) |
|
||||||
{ |
|
||||||
if (globals[v.key].GetType() != v.GetType()) |
|
||||||
{ |
|
||||||
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); |
|
||||||
} |
|
||||||
} |
|
||||||
globals[v.key] = v; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.MinWidth(Mathf.Max(position.width, 300))); |
|
||||||
|
|
||||||
FungusScriptEditor fungusScriptEditor = Editor.CreateEditor(fungusScript) as FungusScriptEditor; |
|
||||||
fungusScriptEditor.DrawVariablesGUI(); |
|
||||||
|
|
||||||
GUILayout.EndScrollView(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,8 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 56836038c02e74487a7bf4c097b96d2b |
|
||||||
MonoImporter: |
|
||||||
serializedVersion: 2 |
|
||||||
defaultReferences: [] |
|
||||||
executionOrder: 0 |
|
||||||
icon: {instanceID: 0} |
|
||||||
userData: |
|
Binary file not shown.
Loading…
Reference in new issue