- Home /
class, function and variable capitalisation
I'm having trouble understanding the capitalisation in the api, perhaps it's my Java background. For example, I would expect Transform to be a class and transform to be a function within a class but when I see stuff like transform.Rotate I am getting really confused?
transform.Find("spawnpoint").transform.position - this I kind of get, position is a variable and transform is an attribute of the current object but how did Find get there, is it a class which is just created on the fly?
Anyone got any ideas or docos on name conventions within Unity??
Cheers
I give a +1 on that because I feel it could be a little confusing at first and maybe this topic explanation could be improved.
Answer by fafase · Apr 22, 2012 at 12:41 PM
http://unity3d.com/support/documentation/ScriptReference/Transform.html
http://unity3d.com/support/documentation/ScriptReference/Component-transform.html
The big idea would be Transform is the component in general while transform is the Transform attached to an object.
transform holds the member functions and variables of the object. So transform.Find("spawnpoint").transform.position means you are into the transform of the object and it has a member function Find that will look for a child of the object and again look for the transform.position of the child object.
BUT if you want an array of Transform object
var array :Transform[];
because you want the type of Transform and those one will have transform.position, transform.rotation and transform.scale which are the 3 main members of the transform.
So Transform= generic term
transform=the actual component in the object.
Any clearer?
Answer by Artoo · Apr 22, 2012 at 03:47 PM
In Unity functions usually start with a capital letter and variables are lowercase. Check out the script reference to get a better feeling for the naming convention: http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.html
Answer by Eric5h5 · Apr 22, 2012 at 01:30 PM
Classes and functions are capitalized, variables are lowercase. Look in the docs for the Component class...you can see that transform is a variable of that class. It's probably something like
class Component {
public Transform transform {
get {return GetComponent(typeof(Transform)) as Transform;}
}
}
Your answer
Follow this Question
Related Questions
Unity JS Syntax Coloring for MonoDevelop 0 Answers
Longest Common Subsequence Recursive Function Error. 1 Answer
Item Scripting Error 2 Answers
if ((this || that) && (that || this)).. Does that work? 3 Answers