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
0
Question by Zamaroth · Mar 21, 2013 at 07:36 PM · javascriptperformanceinspectorclassclasses

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;
 }
Comment
Add comment · Show 2
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 Owen-Reynolds · Mar 21, 2013 at 10:18 PM 0
Share

Could also use the built-in Vector2 class: var position: Vector2; Used like: position.x=3;

avatar image Zamaroth · Mar 22, 2013 at 07:03 PM 0
Share

Yeah I didn´t realize I could make such a variable, thanks

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

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.

Comment
Add comment · 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 Zamaroth · Mar 21, 2013 at 07:42 PM 0
Share

Thanks for quick answer :)

avatar image whydoidoit · Mar 21, 2013 at 08:27 PM 0
Share

No pb! Can you click the tick to mark it answered?

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

13 People are following this question.

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

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


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