Handles.DrawLines lines not showing in scene view
Hi everyone. So here's the problem, I'm trying to make a selection box in the scene view but the lines are not showing up. Here's my code:
 private void DrawSelectionBox(float originX, float originY, float endX, float endY) {
         Debug.Log(originX + " " + originY + " " + endX + " " + endY);
         Vector3 topLeft = new Vector3(originX, originY, 0f);
         Vector3 botLeft = new Vector3(originX, endY, 0f);
         Vector3 botRight = new Vector3(endX, endY, 0f);
         Vector3 topRight = new Vector3(endX, originY, 0f);
 
         Vector3[] lines = { topLeft, botLeft, botRight, topRight };
         int[] indexes = { 0, 1, 1, 2, 2, 3, 3, 0 };
 
         //Handles.DrawLines(lines, indexes);
         //Handles.DrawLine(new Vector3(originX, originY, originY), new Vector3(endX, endY, endY));
         Handles.DrawSolidRectangleWithOutline(lines, new Color(1, 1, 1, 0.2f), new Color(0, 0, 0, 1));
     }
Everything is inside OnSceneGUI and still not showing anything. Please help :/ Thanks in advance!
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by LiloE · Feb 25, 2017 at 03:43 PM
You're using the wrong method :-)
The code should be called from the OnDrawGizmos function like this:
     private void OnDrawGizmos() {
         DrawSelectionBox(1, 1, 6, 2);
     }
This produces the following: 
Thanks for the reply! One question though. That method is in an editor script and i cant use OnDrawGizmos in there. Any ideas on that? I thought of connecting somehow the OnDrawGizmos on the monobehaviour with the editor script but im not sure if that works.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                