Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Using Aline package to draw in edit mode

Discussion in 'Scripting' started by ChickenVegetable, Jul 4, 2023.

  1. ChickenVegetable

    ChickenVegetable

    Joined:
    May 3, 2020
    Posts:
    82
    Hello

    Is it possible to use the Aline draw commands the way you can use Debug.Drawline in the scene view / edit mode?

    It sort of works but it flickers, I am assuming because Update() isn't called frequently enough in edit mode?

    Code (CSharp):
    1. [ExecuteAlways]
    2. public class AlineTester : MonoBehaviour
    3. {
    4.     public Transform from;
    5.     public Transform to;
    6.  
    7.     [ColorUsage(true, true)]
    8.     public Color color = Color.red;
    9.    
    10.     [ExecuteInEditMode]
    11.     void Update () {
    12.         var position2 = to.position;
    13.         var position1 = from.position;
    14.        
    15.         Debug.DrawLine(position1, position2, color); // works
    16.         Draw.Line(position1, position2, color); // works but flickers
    17.     }
    18. }
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    I suppose you might want to check on the Aline support website, see if it is compatible with Unity.

    I will guess that unless Aline is INTENDED for use in the Unity graphics context, it won't work under Unity. Maybe... give it a try!

    This is the Unity3D support site.

    Are you just talking about your AlineTester Monobehaviour class above? If so then it already uses Debug.DrawLine()
     
  3. ChickenVegetable

    ChickenVegetable

    Joined:
    May 3, 2020
    Posts:
    82
    Sorry to clarify, Aline is a Unity package, and it does work, but it flickers when Unity is not in play mode.

    I included the Debug.DrawLine call as an example of how I would like to use Aline. Both those lines of code work, but the Aline version flickers, while the Debug.DrawLine version does not. Sorry for the confusion.
     
  4. dlorre

    dlorre

    Joined:
    Apr 12, 2020
    Posts:
    700
    If it flickers it must be because you're not waiting for the end of frame or something along that line.