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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to Draw a line with a width and no AA?

Discussion in 'Scripting' started by fwalker, Mar 16, 2015.

  1. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    250
    I can use:
    DrawAAPolyLine(float width, params Vector3[] points);

    But then I only have:
    DrawPolyLine(paramsVector3[] points);

    So, how can I draw a line with a width and no AA?

    Thanks
     
  2. shawn

    shawn

    Unity Technologies

    Joined:
    Aug 4, 2007
    Posts:
    552
    Try this:
    Code (CSharp):
    1. Handles.DrawAAPolyLine(EditorGUIUtility.whiteTexture, width, points);
    DrawAAPolyLine uses the texture passed to create an AA effect. Using just a solid white texture should cause it to be aliased.
     
  3. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    250
    Oh I see you mean use:
    DrawAAPolyLine(Texture2D lineTex, float width, paramsVector3[] points);

    and pass it a texture? Not sure how it works but I will look into it.
    I am actually wanting it to NOT be alias. But I will try thing out.
    Thanks.
     
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    This is a farily wonderful thing.
     
  5. shawn

    shawn

    Unity Technologies

    Joined:
    Aug 4, 2007
    Posts:
    552
    If you want it to NOT be aliased, then what's wrong with DrawAAPolyLine (width, points)? AA stands for Anti-Aliased.
     
  6. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    250
    Right I figured but there is no DrawPolyLine (width, points) why? That is what I was after.
     
  7. shawn

    shawn

    Unity Technologies

    Joined:
    Aug 4, 2007
    Posts:
    552
    That's what I told you originally. If you use DrawAAPolyLine with the white texture passed in, it will give you the same effect as DrawPolyLine, which is a line that is aliased.
     
  8. shawn

    shawn

    Unity Technologies

    Joined:
    Aug 4, 2007
    Posts:
    552
    For clarity:

    DrawAAPolyLine (width, points) == Anti-aliased with width
    DrawAAPolyLine (EditorGUIUtility.whiteTexture, width, points) == Aliased with width
    DrawPolyLine (points) == Aliased without width
     
  9. wangshihao

    wangshihao

    Joined:
    Aug 14, 2019
    Posts:
    1
    thanks, veryhelpful
     
  10. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,878
    Please do not necro/resurrect a nearly 5 year old post just to say "thanks".
     
    UnityMaru likes this.