- Home /
Multiple classes inside each other
Hi, I recently started with classes and I have one question. I made class variable, so I can manage it in inspector. I wanted to look it nice so I made few classes inside that class to create some groups for similar variables. It´s working okay, but I´m worried, that those multiple classes will decrease performance. Is that possible?
var something : First;
function Update()
{
//Using variable from second class
something.position.x_Position += 1;
}
class First
{
class Position
{
var x_Position : float;
var y_Position : float;
}
class Size
{
var x_Size : float;
var y_Size : float;
}
var hasFixedSize : boolean;
var position : Position;
var size : Size;
var header : String;
var style : int;
}
Could also use the built-in Vector2 class: var position: Vector2;
Used like: position.x=3;
Yeah I didn´t realize I could make such a variable, thanks
Answer by whydoidoit · Mar 21, 2013 at 07:38 PM
No it's fine - it has a very small impact, but not one to worry about unless you happen to be accessing them millions of times in a loop or something.
Your answer
Follow this Question
Related Questions
Accessing a variable inside a class inside other script... 2 Answers
How do I create a JavaScript class that creates an object with viewable variables in the inspector? 3 Answers
Linking prefabs to classes that are not attatched to gameobjects 1 Answer
Custom JS class error - function is not a member of the class 2 Answers
Change a Class in the inspector 1 Answer