- Home /
 
               Question by 
               Steven-Walker · Oct 30, 2012 at 04:59 PM · 
                inspectorrendertexturedrawinggloninspectorgui  
              
 
              OnInspectorGUI Custom Drawing?
I'm trying to do custom drawing in the inspector or editor window but am not having much luck. I found the following conversation and have tried implementing this as a starting point, but my inspector view is either turning completely white or rendering garbage. http://forum.unity3d.com/threads/134400-How-do-I-draw-in-the-inspector
Here's my javascript version of the code:
 class MyScriptEditor extends Editor {
     public var preview : RenderTexture = null;
 
     function OnInspectorGUI() {
         if(!preview) {
             preview = RenderTexture(256.0, 256.0, 24, RenderTextureFormat.ARGB32);
             preview.Create();
         }
         
         var newPreview : boolean = false;
         if(Event.current.type == EventType.MouseDown && Event.current.button == 0) {
             Debug.Log("Render");
             Graphics.SetRenderTarget(preview);
             
             GL.PushMatrix();
             GL.LoadOrtho();
             GL.Clear(true, true, Color(0,0,0,0));
             GL.Color(Color.red);
             GL.Begin(GL.LINES);
             GL.Vertex3(0.0, 0.0, 0.0);
             GL.Vertex3(100.0, 100.0, 0.0);
             GL.Vertex3(0.0, 100.0, 0.0);
             GL.End();
             GL.PopMatrix();
             
             newPreview = true;
         }
         GUI.DrawTexture(GUILayoutUtility.GetRect(64.0, 64.0), preview);
         
         if(newPreview) Repaint();
     }
 }
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                