- Home /
 
 
               Question by 
               DerHumpink · Jan 07, 2016 at 01:17 PM · 
                editoreditor-scriptinggizmo  
              
 
              Using the arrows of UnityEditor.UI for own inspectors
The new UI system is visualizing the relation between selectables by drawing arrows into the scene view. I would like to visualize relations between gameplay elements in my game and these arrows would be perfect. Is there any way to draw these from my own editor script? 
 
                 
                guivisualizenavigation.png 
                (111.3 kB) 
               
 
              
               Comment
              
 
               
              Answer by Keseren · Jan 07, 2016 at 02:26 PM
You can create some kind of code that generates a line from one point to another and curves it a bit. You can probably use
 Texture Line = new Texture(x2.location - xlocation, y2.location - ylocation);
 Colors[] C = new Colors[Line.width * Line.height];
 Line.SetPixels(C)
 Line.Apply(); //Maybe Line.Apply(false); I don't remember
 
               Then you'll have to use some logic to create the lines in the Colors[] C and use http://docs.unity3d.com/ScriptReference/EditorGUI.DrawPreviewTexture.html
Some tips:
 for (int n = 0; n < C.length; n++){
      int x = n % Line.width; //Here you can get the X you'll be at the texture you're making
      int y = n / Line.width; //Here you can get the Y you'll be at the texture you're making
      Rest of the code here
 }
 
              Your answer