Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
2
Question by hatchnet · Apr 22, 2012 at 11:45 AM · syntax

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

Comment
Add comment · Show 1
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 fafase · Apr 22, 2012 at 03:14 PM 0
Share

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.

3 Replies

· Add your reply
  • Sort: 
avatar image
1

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?

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
avatar image
0

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

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
avatar image
0

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;}
     }
 }
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

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.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

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

Trying to Sort a Multi Dimensional Array 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