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

Can I please... Draw a Line? :)

Discussion in 'Scripting' started by InfiniteAmmo, Jun 3, 2009.

  1. InfiniteAmmo

    InfiniteAmmo

    Joined:
    Aug 12, 2008
    Posts:
    45
    One of my frustrations with Unity3d after coming from a background of creating my own engines in C++ is the lack of flexibility in some areas - where it doesn't really make sense.

    example: Right now I'm trying to make a simple editor in Unity. (not using the unity editor gui, just an editor as a unity application - one that could be enabled in-game)

    I want to be able to create paths, so I've set up editor modes and input so that you can click to create a path. This all works great, except I have no way to actually visualize the path.

    In C++/OpenGL i'd just throw some GL_LINES onto the frying pan and voila, I'd be done.

    In Unity3D, so far I've tried ... Gizmos.DrawLine, which works great... but only in the editor and only if Gizmos are enabled.

    Q1: Is there any way to enable Gizmos in a release build?

    Other than that, I've tired GL.Begin(GL.LINES)... but I can't get it to work properly. Even if I did, AFAIK I wouldn't be able to set the line size.

    Q2: Is there a more Unity3D-acceptable way to do this?

    I feel like I'm fighting the engine, maybe I'm missing something? I don't see why it would make sense to do this with a premade mesh...

    Thanks! :)
     
  2. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    I kinda agree with you on this topic.
    There's the LineRenderer component that you could use.
     
  3. InfiniteAmmo

    InfiniteAmmo

    Joined:
    Aug 12, 2008
    Posts:
    45
    I'd rather not deal with the overhead of the line renderer component if I can avoid it....

    Especially because I'd like to render more than just one line per editable path node.
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,400
    Take a look at this.

    --Eric
     
  5. WillBellJr

    WillBellJr

    Joined:
    Apr 10, 2009
    Posts:
    394
    There have been requests made in the wishlist section for a 2D sprite toolkits - hopefully, our voices will be heard and the tools provided to us in a future update.

    -Will
     
  6. BananaRaffle

    BananaRaffle

    Joined:
    Feb 24, 2009
    Posts:
    85
    Where are those on http://feedback.unity3d.com? Searching for "sprite" or "2d" turns up nothing.
     
  7. InfiniteAmmo

    InfiniteAmmo

    Joined:
    Aug 12, 2008
    Posts:
    45
    I don't need much...

    just being able to use Gizmos.DrawLine + DrawCube in a build would be it.

    or for GL.Begin(GL.LINES) .... etc to actually draw something :roll:
    (not sure what I'm doing wrong there)

    Its easy enough to write your own sprite + animation code. (really easy!)
     
  8. ej2009

    ej2009

    Joined:
    Mar 2, 2009
    Posts:
    353
    same here, ability to draw simple lines would be very nice.

    I actually had to switch my project from Unity to XCode + Quartz just for this reason, very frustrating, but what can you do.

    Sorry, forgot to mention I'm talking about Unity iPhone.
     
  9. bumba

    bumba

    Joined:
    Oct 10, 2008
    Posts:
    358
    same probleme here, since i have no unity pro, my try with linerenderer ended with this "line":


     
  10. ej2009

    ej2009

    Joined:
    Mar 2, 2009
    Posts:
    353
    Perhaps you need to add more vectors to your line? I somehow managed to draw almost straight lines with linerenderer..
     
  11. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,400
    Did you look at the link I provided?

    --Eric
     
  12. tonyd

    tonyd

    Joined:
    Jun 2, 2009
    Posts:
    1,224
    Is it possible to draw/resize a plane with code? If the height is small enough, it would look like a line.
     
  13. bumba

    bumba

    Joined:
    Oct 10, 2008
    Posts:
    358
    yes thats possible, but then you can not say start point is x and endpoint is y. You only could scale the plane
     
  14. tonyd

    tonyd

    Joined:
    Jun 2, 2009
    Posts:
    1,224
    Well... that kinda sucks. :)

    I need to draw a line or rectangular shape for the game I'm working on, and I can't use GL lines as I can't afford Pro (for now).
     
  15. WillBellJr

    WillBellJr

    Joined:
    Apr 10, 2009
    Posts:
    394
    Perform a search, type in "Line" change the specs to "any..."

    Select the Wish List forum and run it.

    There may be a minimum search term length cause when I entered "2D" I got back nothing as well, even though you could see my post "Better 2D Graphics" within the first page.

    -Will