using UnityEngine; using System.Collections; public class Tools{ static Material lineMaterial; /* public static void DrawRectangle(Rect rect, Color color){ DrawRectangle (rect.x, rect.y, rect.width, rect.height, color); } public static void DrawRectangle(float x, float y, float width, float height, Color color){ CreateLineMaterial (); lineMaterial.SetPass (0); GL.Begin(GL.QUADS); GL.Color(color); GL.Vertex3(x, y, 0); GL.Vertex3(x, y + height, 0); GL.Vertex3(x + width, y + height, 0); GL.Vertex3(x + width, y, 0); GL.End(); }*/ public static Vector3 WorldToGuiPoint(Vector3 point){ var pt = Camera.current.WorldToScreenPoint (point); pt.y = Camera.current.pixelHeight - pt.y; return pt; } public static void BeginGui(bool verticalFlip = true){ GL.PushMatrix(); if (verticalFlip) { GL.LoadPixelMatrix (0, Camera.current.pixelWidth, Camera.current.pixelHeight, 0); } else { GL.LoadPixelMatrix (0, Camera.current.pixelWidth, 0, Camera.current.pixelHeight); } } public static void EndGui(){ GL.PopMatrix(); } }