- Home /
How do I show a Classes Vars in the inspector (Javascript)??
Just setting them to public does NOT work. In this 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");
}
}
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 things 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.
you can instantiate gameobjects with the constructor just fine. Instantiating components with the default constructor is not supported. (use AddComponent ins$$anonymous$$d)
Oh, good point - thanks for the correction. I mixed up components and GameObjects, so I removed that part of the answer.
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.
Nope. I tried putting extends System.Object but the vars atre still not showing up.
??
Hold the bus ... you are assigning to a variable that does not exist... scrollListContainer.
Probably doesn't show in the inspector because it hasn't compiled.
Your answer
Follow this Question
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
Javascript Class Update 2 Answers