Search Unity

Hide object and draw line

Discussion in 'Scripting' started by scrobby4, Jul 1, 2010.

  1. scrobby4

    scrobby4

    Joined:
    Sep 3, 2009
    Posts:
    9
    Hi,

    I have two simple issues related to scripts using C#:

    1- I have a plane primitive and want to make it appear and disappear depending on some variable state. How do I do that?

    2- I was trying to use the DrawLine function in the Update method of a script I am creating to draw a line between two points when runnign the EXE of my game, but the line never shows up. I am trying something just like the sample code in the reference manual:

    Code (csharp):
    1. Debug.DrawLine (Vector3.zero, new Vector3 (1, 0, 0), Color.red);
    Should I be using adding this code somwhere else? Do I need to enable Debug mode somehow? Should I be using Handles.DrawLine or Gizmos.DrawLine instead?


    Thank you all.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    1. Set the object's renderer to enabled or disabled depending on that variable.

    2. The Debug class only works in the editor. For line drawing in builds, try this.

    --Eric
     
  3. scrobby4

    scrobby4

    Joined:
    Sep 3, 2009
    Posts:
    9
    Thanks, Eric. 1 worked and I will try 2 later on. Right now for 2, since I only wanted on line, I am using a scaled plane primitive (the one I am hiding and showing). GPU Inefficient compared to a line, I know. But, well, there ain't that many objects in my one room scene.