Browse Source

Fixed serialising command view width

master
chrisgregan 11 years ago
parent
commit
088b6d2375
  1. 18
      Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs
  2. 3
      Assets/Fungus/FungusScript/Scripts/FungusScript.cs

18
Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs

@ -8,7 +8,6 @@ namespace Fungus.Script
{ {
public class FungusScriptWindow : EditorWindow public class FungusScriptWindow : EditorWindow
{ {
float commandViewWidth;
bool resize = false; bool resize = false;
Rect cursorChangeRect; Rect cursorChangeRect;
public const float minViewWidth = 300; public const float minViewWidth = 300;
@ -23,8 +22,6 @@ namespace Fungus.Script
void OnEnable() void OnEnable()
{ {
commandViewWidth = minViewWidth;
cursorChangeRect = new Rect(this.position.width - commandViewWidth, 0, 4f, this.position.height);
} }
public void OnInspectorUpdate() public void OnInspectorUpdate()
@ -53,7 +50,7 @@ namespace Fungus.Script
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
DrawScriptView(fungusScript); DrawScriptView(fungusScript);
ResizeViews(); ResizeViews(fungusScript);
DrawCommandView(fungusScript); DrawCommandView(fungusScript);
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
} }
@ -82,7 +79,7 @@ namespace Fungus.Script
scrollViewRect.yMax += position.height * bufferScale; scrollViewRect.yMax += position.height * bufferScale;
// Calc rect for left hand script view // Calc rect for left hand script view
Rect scriptViewRect = new Rect(0, 0, this.position.width - commandViewWidth, this.position.height); Rect scriptViewRect = new Rect(0, 0, this.position.width - fungusScript.commandViewWidth, this.position.height);
// Clip GL drawing so not to overlap scrollbars // Clip GL drawing so not to overlap scrollbars
Rect clipRect = new Rect(fungusScript.scriptScrollPos.x + scrollViewRect.x, Rect clipRect = new Rect(fungusScript.scriptScrollPos.x + scrollViewRect.x,
@ -156,10 +153,9 @@ namespace Fungus.Script
GLDraw.EndScrollView(); GLDraw.EndScrollView();
} }
void ResizeViews() void ResizeViews(FungusScript fungusScript)
{ {
cursorChangeRect.x = this.position.width - commandViewWidth; cursorChangeRect = new Rect(this.position.width - fungusScript.commandViewWidth, 0, 4f, this.position.height);
cursorChangeRect.height = this.position.height;
GUI.color = Color.grey; GUI.color = Color.grey;
GUI.DrawTexture(cursorChangeRect, EditorGUIUtility.whiteTexture); GUI.DrawTexture(cursorChangeRect, EditorGUIUtility.whiteTexture);
@ -172,9 +168,9 @@ namespace Fungus.Script
} }
if (resize) if (resize)
{ {
commandViewWidth = this.position.width - Event.current.mousePosition.x; fungusScript.commandViewWidth = this.position.width - Event.current.mousePosition.x;
commandViewWidth = Mathf.Max(minViewWidth, commandViewWidth); fungusScript.commandViewWidth = Mathf.Max(minViewWidth, fungusScript.commandViewWidth);
commandViewWidth = Mathf.Min(this.position.width - minViewWidth, commandViewWidth); fungusScript.commandViewWidth = Mathf.Min(this.position.width - minViewWidth, fungusScript.commandViewWidth);
} }
if(Event.current.type == EventType.MouseUp) if(Event.current.type == EventType.MouseUp)
{ {

3
Assets/Fungus/FungusScript/Scripts/FungusScript.cs

@ -27,6 +27,9 @@ namespace Fungus.Script
[HideInInspector] [HideInInspector]
public Vector2 commandScrollPos; public Vector2 commandScrollPos;
[HideInInspector]
public float commandViewWidth = 300;
public float stepTime; public float stepTime;
public Sequence startSequence; public Sequence startSequence;

Loading…
Cancel
Save