• 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 /
This question was closed Dec 03, 2015 at 11:46 AM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
9
Question by Jeff Ciaccio · Jul 01, 2010 at 02:47 AM · debug

Viewing private variables in the inspector

var newObject : Transform;
private var cubeCount = 0;
function Update () {
if (Input.GetButtonDown("Fire1")) {
Instantiate(newObject, transform.position, transform.rotation);
Debug.Log("Cube created");
cubeCount++;
}
}

This code is in the scripting tutorial, and it says that the private var cubeCount will show up in the Inspector while running the game. I tried this out, but it did not appear. Can somebody tell me where to look to find this? Viewing hidden variables would be quite handy!

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

3 Replies

  • Sort: 
avatar image
5
Best Answer

Answer by aemason · Jul 15, 2012 at 10:06 PM

Just wanted to point out the private variables can be changed via inspector, in c# I can accomplish this task by adding [SerializeField] in front of a private iVar like so "[SerializeField] private Texture[] textures;".

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 janoonk · Nov 11, 2012 at 10:07 PM 0
Share

In Javascript you can use @SerializeField in front of the private variable so you can change it at runtime in inspector when inspector is in Debug mode. See also http://docs.unity3d.com/Documentation/ScriptReference/SerializeField.html

avatar image Neonalig · Sep 27, 2017 at 02:43 AM 2
Share

Probably a bit late, but another way to temporarily view private variables is to enable Debug view mode. When finished, just swap back to Normal mode. See attached image How to enable Debug $$anonymous$$ode

avatar image
18

Answer by qJake · Jul 01, 2010 at 02:51 AM

If you want to only view it and not modify it at all, change the Inspector to Debug Mode.

If you want to be able to change the value in the Inspector, it cannot be private. You must explicitly set it to public (which shouldn't affect your script in any way, if you change that). private is also implied, you don't need to specify it if you don't want to, you could just do var cubeCount = 0; if you want to. Nevermind, public is implied, not private...stupid UnityScript...

Comment
Add comment · Show 8 · 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 Mike 3 · Jul 01, 2010 at 02:56 AM 0
Share

Public is implied in js, but pretty picture!

avatar image qJake · Jul 01, 2010 at 02:57 AM 0
Share

Well, then I'll add that to the list of reasons I hate UnityScript, thanks. :)

avatar image Mike 3 · Jul 01, 2010 at 03:00 AM 0
Share

It's on my (long) list too

avatar image bradmarxmoosepi · Nov 04, 2012 at 07:13 PM 0
Share

That's a cool feature, just saw it after reading this post :) Thanks!

avatar image salat · Jun 16, 2014 at 01:48 PM 10
Share

add [SerializeField] to make it visible in Normal mode

Show more comments
avatar image
8

Answer by Tetrad · Jul 01, 2010 at 02:49 AM

Set the inspector to debug mode. Right click on the tab and click "debug".

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

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

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

Network Usage Statistics 1 Answer

Binnary Formatter working nicely in editor - but I have crashing after scene load paramteras on both iOS and Android device 0 Answers

Debug.Log Override? 3 Answers

Monodevelop 4.0.1 breakpoints won't work. 0 Answers

Debug.log not working when run from mobile 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