Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by .hooligan · Feb 22, 2012 at 02:03 AM · debug

Cant use Debug.Log

I have a static class that I want to log some info to the console.

Its a static class so I can't extend MonoBehavoir. I tried using Debug.Log() but it doesn't recognise it.

Is there a certain using I need to include?

I've seen examples where no using has been included in their class and they could use Debug.Log()

Comment
Add comment · Show 4
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 Eric5h5 · Feb 22, 2012 at 03:37 AM 1
Share

$$anonymous$$aybe you called your class Debug.

avatar image Default117 · Feb 22, 2012 at 03:44 AM 2
Share

Does it still not work if you try: UnityEngine.Debug.Log("your message");

avatar image .hooligan · Feb 22, 2012 at 09:18 AM 0
Share

Perfecto! Thanks Dewald, Debug.Log() doesn't work but UnityEngine.Debug.Log(); works a treat. Thanks

avatar image Angolmagyar · Apr 09, 2021 at 08:11 PM 0
Share

Sorry for reviving a dead post, but I had this problem and it was a simple mistake for me, I had to import the UnityEngine - i.e.: "using UnityEngine;" at the top. Was this your issue, perhaps? Maybe you don't care at this point, since 2012, but in case anyone else like me stumbles on this issue, this was my fix.

3 Replies

· Add your reply
  • Sort: 
avatar image
-2

Answer by tianjishu · Feb 22, 2012 at 03:00 AM

Debug is not static, so you can set up function for static function and class for unstatic function .

Comment
Add comment · Show 1 · 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 Eric5h5 · Feb 22, 2012 at 03:37 AM 0
Share

Debug is static:

static function Log (message : object) : void

avatar image
0

Answer by Suyuanhan · Feb 22, 2012 at 04:30 AM

Must be in a static class? You could try: public class TestDebug : MonoBehaviour { public static void ShowDebug(){ Debug.Log("message"); }

and you can use it by: TestDebug.ShowDebug();

Comment
Add comment · Show 1 · 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 Eric5h5 · Feb 22, 2012 at 04:36 AM 0
Share

Static or not static doesn't matter. Debug.Log is a static function and can be called from anywhere.

avatar image
0

Answer by samf1111 · Jul 26, 2021 at 07:26 PM

If you spelled MonoBehaviour the same way in your script as you did in your question, then the error is that you need to fix your spelling. That's all! :)

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

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

11 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

Related Questions

Filing and debuging web plugin crashes 1 Answer

"It is not possible to invoke an expression of type 'boolean'" in switching cameras 1 Answer

Turn off blue mesh lines 2 Answers

Debug Wrapper Class 6 Answers

fall animation triggered via rigidbody velocity 0 Answers


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