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 fjalla · Aug 06, 2013 at 07:08 PM · optimizationvariablesnameparsinglevel-editor

A question of optimization: use a script with variables or use the object name?

Hi. I have script where you can build a level just by moving walls (like in Portal 2) I'm currently working on highlighting walls so that you can move them (already got the "building part" of the script done - long story).

It basically works like this:

You have an built-in Array (with six wall slots) in an Array (z-axis) in an Array (y-axis) in an Array (x-axis).

You changing the max size of the level that you want by changing the size of the arrays.

So when you want to get a reference to the 4th wall "grid position" of x=5,y=7,z=3, you just type

 x[5].y[7].z[3].w[4].o

("o" as for object, its a class with o as object, h as if highlighted)

It works for now. But as I mentioned, I need to find a way to highlight the walls when you click them.

Now the names of the walls look like (for the example above) "5734". I thought about reading those numbers to get a reference in the arrays, but it's only easy if the numbers are <10. If they were larger, I would have to find a way to change "5" to "005" and "50" to "050", set it to the name of the wall, and read it when you click on it to highlight it.

When you think about that, it's quite hard to achieve and doesn't affect the performance positively.

So I'm asking: is it better to use the name thing with parsing etc. or to just put a simple script with variables only on each of the walls with their XYZW?

Thanks.

Comment
Add comment
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

1 Reply

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

Answer by Ejlersen · Aug 06, 2013 at 07:25 PM

I would go with a script that has its indices.

Reason:

You don't need to parse a string to get its indices, so its faster.

Comment
Add comment · Show 5 · 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 fjalla · Aug 06, 2013 at 07:34 PM 0
Share

Hmm... Ive thought about that, but Ive got sometimes even thousands of walls, so a thousand of scripts... Doesn't that affect the performance?

avatar image Ejlersen · Aug 06, 2013 at 07:58 PM 0
Share

True, but if you have thousands of walls, which is thousands of game objects with thousands of colliders. Then a small script like that is the least of your problems.

avatar image fjalla · Aug 07, 2013 at 10:08 AM 0
Share

I guess your right... thanks :)

avatar image Ejlersen · Aug 07, 2013 at 05:18 PM 0
Share

Remember to mark the question as answered :)

avatar image fjalla · Aug 08, 2013 at 04:32 PM 0
Share

Wait :) Ill test it first :D

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

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

Related Questions

C# basic perfomance question 2 Answers

How to access scripts other than by name. 1 Answer

Optimized Scripting - Variables 1 Answer

Static variables optimization 2 Answers

Which is more optimal? Defining variables or calling Resources.Load? 2 Answers


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