Browse Source

Added scroll view and DrawRect to GLDraw

master
chrisgregan 10 years ago
parent
commit
5527e830c6
  1. 33
      Assets/Fungus/FungusScript/Editor/GLDraw.cs

33
Assets/Fungus/FungusScript/Editor/GLDraw.cs

@ -86,6 +86,20 @@ public class GLDraw
clippingEnabled = false; clippingEnabled = false;
} }
public static Vector2 BeginScrollView(Rect position, Vector2 scrollPos, Rect viewRect, Rect clipRect)
{
clippingEnabled = true;
clippingBounds = clipRect;
return GUI.BeginScrollView(position, scrollPos, viewRect);
}
public static void EndScrollView()
{
GUI.EndScrollView();
clippingBounds = new Rect(0, 0, Screen.width, Screen.height);
clippingEnabled = false;
}
public static void CreateMaterial() public static void CreateMaterial()
{ {
if (lineMaterial != null) if (lineMaterial != null)
@ -146,6 +160,25 @@ public class GLDraw
GL.End(); GL.End();
} }
public static void DrawRect(Rect rect, Color color)
{
if (Event.current == null)
return;
if (Event.current.type != EventType.repaint)
return;
CreateMaterial();
// set the current material
lineMaterial.SetPass( 0 );
GL.Begin( GL.QUADS );
GL.Color( color );
GL.Vertex3( rect.xMin, rect.yMin, 0 );
GL.Vertex3( rect.xMax, rect.yMin, 0 );
GL.Vertex3( rect.xMax, rect.yMax, 0 );
GL.Vertex3( rect.xMin, rect.yMax, 0 );
GL.End();
}
public static void DrawBox(Rect box, Color color, float width) public static void DrawBox(Rect box, Color color, float width)
{ {
Vector2 p1 = new Vector2(box.xMin, box.yMin); Vector2 p1 = new Vector2(box.xMin, box.yMin);

Loading…
Cancel
Save