• 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
Question by Grimmy · Aug 05, 2010 at 11:45 AM · javascriptinspectorclass

How do I show a Classes Vars in the inspector (Javascript)??

Just setting them to public does NOT work. In t$$anonymous$$s example my test var is NOT displayed when a new instance of the class is created..

class ScrollListContainer {

 public var test:int;

 function Create()
 {

 scrollListContainer = new GameObject ("Scroll List COntainer");
 }

}

Comment

People who like this

0 Show 0
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

2 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by jashan · Aug 06, 2010 at 05:10 AM

You seem to have an odd mix of JavaScript and UnityScript here. In UnityScript, you don't really need

class ScrollListContainer

in fact, it'll make t$$anonymous$$ngs a bit more complicated for you because if you do that you probably have to explicitly say that it's a MonoBehaviour, so you'd do:

class ScrollListContainer extends MonoBehaviour

Then, when your script compiles, you can attach it to a game object, and then your public variable will show up in the inspector.

Comment

People who like this

0 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 Lucas Meijer 1 ♦♦ · Aug 06, 2010 at 05:00 PM 0
Share

you can instantiate gameobjects with the constructor just fine. Instantiating components with the default constructor is not supported. (use AddComponent instead)

avatar image jashan · Aug 08, 2010 at 07:58 PM 0
Share

Oh, good point - thanks for the correction. I mixed up components and GameObjects, so I removed that part of the answer.

avatar image

Answer by Peter G · Aug 05, 2010 at 11:57 AM

Most of the time it should do it automatically, but try adding the System.Serializable attribute and explicitly inheriting from System.Object.

Comment

People who like this

0 Show 4 · 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 Grimmy · Aug 05, 2010 at 12:04 PM 0
Share

Nope. I tried putting extends System.Object but the vars atre still not showing up.

??

avatar image cncguy · Aug 05, 2010 at 03:27 PM 0
Share

How are you declaring the instance of your class?

avatar image cncguy · Aug 05, 2010 at 03:28 PM 0
Share

Hold the bus ... you are assigning to a variable that does not exist... scrollListContainer.

avatar image cncguy · Aug 05, 2010 at 03:29 PM 0
Share

Probably doesn't show in the inspector because it hasn't compiled.

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

No one has followed this question yet.

Related Questions

Multiple classes inside each other 1 Answer

Is it possible to create a script dinamic like animation>size controling the Elements variables? 1 Answer

Change a Class in the inspector 1 Answer

How do I create a JavaScript class that creates an object with viewable variables in the inspector? 3 Answers

Should I manually delete my custom class instances? 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