Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
5
Question by Dubious-Drewski · Sep 12, 2012 at 04:58 AM · debuglinevisibledebug.drawline

Really Simple: Debug.DrawLine just will not show up

This should be really easy to solve. I must be high on something, because I cannot figure it out.

     function Update () {
         Debug.DrawLine(Vector3(200,200,200), Vector3.zero);
         print("You should see a line");
     }

This code will print the text, but it will not draw any lines. Why not? I've got to be missing something simple.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

6 Replies

· Add your reply
  • Sort: 
avatar image
10
Best Answer

Answer by hirenkacha · Sep 12, 2012 at 05:15 AM

it is because it will draw a line for a single frame. if you want to see a line for longer use this. `Debug.DrawLine(Vector3(200,200,200), Vector3.zero, Color.green, 2, false);`

where `DrawLine (start : Vector3, end : Vector3, color : Color = Color.white, duration : float = 0.0f, depthTest : boolean = true)` .

Comment
Add comment · Show 7 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Dubious-Drewski · Sep 12, 2012 at 05:28 AM 2
Share

Thank you for your answer, but it's something else that is causing this problem, it seems.

I already knew about the duration variable, but I copy and pasted your code to try it just in case. I even changed the duration to 20. Still no line.

I only have a simple plane and a first person controller in my scene, both near (0,0,0). But there is no line.

(If I put the DrawLine command in an Update() function, won't it redraw every frame? If so, I don't understand why I would need a duration value)

avatar image hirenkacha · Sep 12, 2012 at 05:31 AM 9
Share

DrawLines are only visible in scene view not in game view. i hope you are aware of it.

avatar image hirenkacha · Sep 12, 2012 at 05:38 AM 0
Share

i found this working on my pc for c#.

Debug.DrawLine(new Vector3(200f,200f,200f), Vector3.zero, Color.green, 2f, false);

avatar image Dubious-Drewski · Sep 12, 2012 at 05:50 AM 1
Share

Ohhh okay. I had my Unity windows set to full screen, so that hitting "play" would switch over to full screen GameView, and I would never see the lines being rendered in SceneView. I didn't know they wouldn't render in Gameview.

Thank you. That makes sense now, but now it seems I am forced to create a LineRenderer object in order to draw a simple debug line. That seems silly to me, but alright, if that's what I must do.

Thank you again.

avatar image CHPedersen · Sep 12, 2012 at 07:00 AM 11
Share

Lines do render in gameview, but they count as gizmos, so you have to have Gizmos enabled. It's the button in the top right corner of the game view.

Show more comments
avatar image
21

Answer by DefaultPain · Aug 06, 2016 at 07:50 PM

when u click on the play button to play the scene,u have to enable gizmos,which are on the top right corner.then u will see the lines.case closed.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image xjfscrat · Aug 08, 2017 at 07:20 AM 0
Share

I can only see the other gizmos like light, but no line, line only appears on scene view, why...

avatar image $$anonymous$$ xjfscrat · Sep 02, 2018 at 07:57 AM 1
Share

Each view has its own gizmos option, so you should also activate gizmos in your game view.

avatar image Phoskryfes · Aug 29, 2019 at 11:17 AM 0
Share

Exactly what I needed.

avatar image
1

Answer by hamy6342 · Sep 28, 2017 at 07:02 PM

@CHPedersen Have Gizmos button enabled but still line won't show up even in scene view.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
-1

Answer by Lokiare · Oct 30, 2014 at 05:55 PM

Because time is independent of frame rate you have to tell it to draw the line for the time between frames:

Debug.DrawLine(Vector3(200,200,200), Vector3.zero, Color.green, Time.deltaTime, false);

If you use something other than "Time.deltaTime" then you either won't see the line or it will create tracers (multiple lines) and you can only see the lines in the editor view so make sure you take your game out of full screen when testing it.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Aeroxima · Aug 08, 2018 at 08:15 PM

I know this is old (comes up in google), but I got away with a cube scaled to (0.01, 0.01, 10) for my purposes. I made it 50% transparent and turned off shadows (cast and received, in its mesh renderer).

Play mode line


playmode-line.png (103.9 kB)
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Converting Debug.drawlines to in-game lines? [screenshot inside] 3 Answers

Not getting where error comes from which line when debugging on Android 1 Answer

Calculate needed resolution to draw curve from line segments in editor 1 Answer

Debug.DrawLine problem 1 Answer

Debug.DrawLine doesn't work 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges