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 Galactic_Muffin · Mar 11, 2015 at 02:39 PM · arrayoptimizationliststostring

Simple optimization question on array vs hardcoding.

Hey guys :3 So you will have to forgive my ignorance as i've been coding in unity for only over a month now. but I was trying to find answers in the documentation searching up keywords like arrays and hardcoding in google but with no clear answers. This isn't really a problem, more so just curious what is more appropriate way to code based on this circumstance:

so all i have is an effect in Ugui where futuristic UI elements have random numbers "calculating" for added futuristic effect. the numbers are only there for aesthetics.

to get the changing numbers i currently use a corutine set to .1 WaitForSeconds that multiplies a float by random.range and outputs that number to string. the effect looks great, however because the number is something i don't care about and can literally be anything, would it be more efficient to simply hardcode lets say 13 different numbers and iterate between them in a for loop? I know they say hardcoding should be avoided as much as possible but in this circumstance would it make more sense to do so just so it's not processing otherwise numbers we don't care about?

thanks for any help :)

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

Answer by fffMalzbier · Mar 11, 2015 at 02:46 PM

The processing power is not really a issue but if you like to trade the bit processing power and probably regularly memory allocations against a small fixed memory block for storing the numbers sure why not.

If you have a missive amount of thous scripts in your scene, you may be interested in storing it in a static array so all your script can access the same numbers without allocation them again and again.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to access individual class elements, that has an array, that is in a list for c# 1 Answer

How can you do calculations on two lists? 1 Answer

List out all Array Values. 1 Answer

how don't show some screen resolutions in my dropdown? 1 Answer

FindGameObjectsWithTag alternative for better perfomance 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