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

What type of line is that?

Discussion in 'Scripting' started by Phocus, Jul 11, 2015.

  1. Phocus

    Phocus

    Joined:
    Jul 6, 2015
    Posts:
    18
    I have been trying to draw a line that looks like that. I have tried everything. Can someone tell me what type of line would do that? is it a texture or sprite or something?

    Unity 5 2d

    upload_2015-7-10_20-21-37.png
     
  2. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
  3. Phocus

    Phocus

    Joined:
    Jul 6, 2015
    Posts:
    18

    Attached Files:

  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    A LineRenderer won't work for that because of the rounded ends. You need to build it in sections with the appropriate UV mapping using a mesh or UIVertices. Or, yes, just buy Vectrosity if you don't want to fiddle around with that stuff, since it will do exactly that. ;)

    --Eric
     
  5. Phocus

    Phocus

    Joined:
    Jul 6, 2015
    Posts:
    18
    Wait, are you the guy who wrote Vectrosity? If you say it will do it I will click buy right now!
     
  6. Phocus

    Phocus

    Joined:
    Jul 6, 2015
    Posts:
    18
    Wait, are you the guy who wrote Vectrosity? If you say it will do it I will click buy right now!
     
  7. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    He said it! ;)
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Indeed, I am that guy. And sluice is correct: I said it. ;) Quick screenshot...you can of course set color/transparency/etc. as desired:

    Screen Shot 2015-07-10 at 9.41.23 PM.png

    --Eric
     
  9. Phocus

    Phocus

    Joined:
    Jul 6, 2015
    Posts:
    18
    Bought. Going to learn it . Thank you !!!!
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Thank you; let me know if you have any questions. :)

    --Eric
     
  11. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    berry smooth ;)
     
  12. Phocus

    Phocus

    Joined:
    Jul 6, 2015
    Posts:
    18

    What am I doing wrong?

    I imported only Vectrosity4 (using unity 5);
    imported the name space with (C#)
    using Vectrosity;

    and i get the screen shot below.
     

    Attached Files:

  13. Phocus

    Phocus

    Joined:
    Jul 6, 2015
    Posts:
    18
    I clicked around and found it. After unity imported it, I still had to go to Assest->Import Package-> Custom and choose the Vectrosity4 Folder.
     
  14. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can just double-click on the Vectrosity4 package.

    --Eric
     
  15. Phocus

    Phocus

    Joined:
    Jul 6, 2015
    Posts:
    18
    Can you send me your texture file for the rounded corners. I am not understanding how a textfile works and need an example.
     
  16. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It's from the EndCap demo, so you already have it.

    --Eric
     
  17. Phocus

    Phocus

    Joined:
    Jul 6, 2015
    Posts:
    18
    I can not get endcap.mirror to work. Can someone see what I am doing wrong.

    publicclassDrawingLines : MonoBehaviour {
    Vector3[] linePoints = newVector3[10];
    Vector LinemyLine;

    public MaterialmyMat;
    public Texture2Dtexture;

    public GameObjecta1;
    public GameObjecta2;


    voidStart () {
    VectorLine.SetEndCap ("RoundedEnd", EndCap.Mirror,myMat,texture);
    linePoints [0] = a1.transform.position;
    linePoints [1] = a2.transform.position;

    myLine = newVectorLine("myLine", linePoints, myMat, 5.0f,LineType.Discrete);
    myLine.lineWidth = 20f;
    myLine.endCap = "RoundedEnd";
    myLine.Draw ();
    }




    I get this.
    upload_2015-7-11_11-59-22.png
     
  18. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You're only using the first two points in the Vector3 array, but you defined it to have 10 points. Since you're only using two points, the array should have only two entries. (Also, please use code tags when posting code.)

    --Eric
     
  19. Phocus

    Phocus

    Joined:
    Jul 6, 2015
    Posts:
    18
    Is it possible to do no fill? I dont see that in the documentation? like a hollow outline?
     
  20. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Probably the easiest way to do that is to use a shader, though you could make the outline itself with Vectrosity (so you wouldn't actually use textures or end caps in that case).

    --Eric