Hello Guest

Author Topic: Drawing lines using the GL class  (Read 6153 times)

Artheus

  • Newbie
  • *
  • Posts: 19
    • View Profile
Drawing lines using the GL class
« on: January 20, 2014, 09:21:23 pm »
I'm trying to draw the paths of my units using code from this page: http://wiki.unity3d.com/index.php?title=VectorLine but can't get anything to show up.

Does anyone know of a good solution to draw things to the screen?  Does the GL class even work with 2d toolkit?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Drawing lines using the GL class
« Reply #1 on: January 20, 2014, 09:33:15 pm »
GL works fine with 2D Toolkit. I'm not sure about that particular bit of code - it doesn't seem to be setting any matrices. I've used it before so I couldn't give you specific advice - I'd look into setting the projection matrix from the camera first. The other thing worth looking into - try scaling the lines, your camera might be a bit bigger / smaller than the size this code expects.

Artheus

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Drawing lines using the GL class
« Reply #2 on: January 20, 2014, 09:53:12 pm »
Do you have any examples using the GL class?  And I'm just using the points from from my units position and it's path, what kind of transformation do I need to do?
« Last Edit: January 20, 2014, 09:55:39 pm by Artheus »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Drawing lines using the GL class
« Reply #3 on: January 20, 2014, 10:01:30 pm »
No examples off hand. What camera are you using and does that example code work with a normal orthographic camera?

Artheus

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Drawing lines using the GL class
« Reply #4 on: January 20, 2014, 10:10:04 pm »
I'm just using the default 2d toolkit camera set to orthographic and no, it doesn't work with a unity camera set to orthographic.  What does that mean?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Drawing lines using the GL class
« Reply #5 on: January 20, 2014, 10:59:34 pm »
If it doesn't work with an ortho camera, it isn't going to work with a tk2dCamera. It suggests the script isn't going to work properly - perhaps was written for an older version of Unity? tk2d doesn't do anything special here, you will need to find one that works with a normal unity camera for it to work with the tk2dCamera.

At the end of the day drawing lines with GL is terribly inefficient, its far better to build your own mesh and draw it, or use Vectrosity or something like that.

Artheus

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Drawing lines using the GL class
« Reply #6 on: January 21, 2014, 10:25:24 pm »
I wanted to avoid Vectrosity for as long as possible (30 bucks is kinda steep) but I bought it now and it works perfectly.  Thanks for the help.

Crow1

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Drawing lines using the GL class
« Reply #7 on: April 27, 2014, 09:32:44 am »
I wanted to avoid Vectrosity for as long as possible (30 bucks is kinda steep) but I bought it now and it works perfectly.  Thanks for the help.
Hi Artheus,

could you post an example script, how you got Vectrosity to work with the 2D Toolkit cam?

Best regards,
Josef