• 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
0
Question by sean244 · Dec 21, 2017 at 04:15 AM · editorinspectorpropertiesserializefield

If I have a bool method, how can I see in the inspector whether it returns true or false?

I know that bool variables can be public or use SerializeField to show up in the inspector, but what about a bool method? How can I see in the inspector whether that method returns true or false?

Comment
Add comment · Show 1
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 uk007singh · Dec 21, 2017 at 04:26 AM 1
Share

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Mazer83 · Dec 21, 2017 at 04:21 AM

You don't. The inspector can't show you what values methods are returning. If you want to see that, use the debugger. Using monodevelop, place a breakpoint (F9 on the line) where the method is being called, press F5 to connect the debugger to Unity. Run your game in unity with the play button. When the method gets called, the program will halt execution at your breakpoint, and you can step through the lines of code bit by bit with F10. You can hover over variables to see what they are. Press F5 again to continue the program as normal.

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 sean244 · Dec 21, 2017 at 04:37 AM 0
Share
avatar image Mazer83 sean244 · Dec 21, 2017 at 04:54 AM 0
Share
avatar image DreadKyller Mazer83 · Dec 21, 2017 at 05:05 AM 0
Share
avatar image
0

Answer by DreadKyller · Dec 21, 2017 at 05:03 AM

Mazer83's answers is also not correct. A standard view of the inspector can't display the value of a function. And to set the value of a public boolean would require some point of entry that updates whenever a change is made. During runtime t$$anonymous$$s isn't a problem, however if you wish to display t$$anonymous$$s value outside of runtime, w$$anonymous$$le editing, then you'll have to deal with custom editors. These are scripts that allow you to manually draw the inspector window for a specific component type, they provide far more powerful functionality for editing, however are more complicated to design. https://docs.unity3d.com/Manual/editor-CustomEditors.html

Alternatively as that page also describes, you can add the [ExecuteInEditMode] to have the script get ran w$$anonymous$$le not playing, depending on the complexity of the script t$$anonymous$$s may or may not be a good option.

Although as for Mazer83's answer, w$$anonymous$$le Debug.Log and setting the value during runtime will work fine for you in t$$anonymous$$s case, it's still a very wise choice to get used to the debugger, because not all problems can be solved with simple logging, and even if a problem can be, often times the debugger is far, far more powerful. People wouldn't have designed debuggers if printing to console solved everyt$$anonymous$$ng.

Comment
Add comment · Show 2 · 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 Mazer83 · Dec 21, 2017 at 05:17 AM 0
Share
avatar image DreadKyller Mazer83 · Dec 21, 2017 at 05:27 AM 0
Share

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

99 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 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 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 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 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

Fill/populate [SerializeField] automatically via script in editor mode? 3 Answers

Why can't a MonoBehaviour subtype with generic arguments be serialized in a list since Unity 4.5? 0 Answers

Custom Inspector. Aligning properties? 1 Answer

Custom names for variables (array-elements!!) in the inspector?? 3 Answers

Showing properties from a base class in inspector? 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