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 reptilebeats · Jan 19, 2012 at 01:09 AM · iphoneperformance

performance query

im thinking using updates or fixed updates can be juicy if theres a lot of stuff in them as these are checked however many times a second,

so say for instance i have a button that accelerates a bike, runs a sound, an animation, and some other stuff, would it be more effective to have one script in an empty object that basically updates checking if i have pressed a button and when i do a script inside that activates all the other components linked to this button.

or would this cause maybe delay from me hitting the button, enable'ing the other script and then runnning it..

or maybe it would be better to have the script with the update fuction only checking to see if i hit the button and then if i do it runs another function in the script which is my acceleration and so on..

can i have your views on this as i would like to get a head start on saving performance in the long run when more effects, sounds,scripts,objects and so on are added to my overall game.

bare in mind that i am creating my game for the iphone and would like it if possible to be able to run on older gen phones without lag, if not i could always make a less visual effects version for them... i would also like to go onto android but thats another £300 and the phones vary so much i aint guna get into it for a while.

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
0

Answer by jahroy · Jan 19, 2012 at 01:15 AM

If you're going to use Unity GUI to draw your button (which makes perfect sense) you will draw the button every frame (which is fine).

If the button is pressed, you will call a function (or functions).

These functions will only get called during the frame the button is pressed.

What they do after that is up to you.

They might change the value of a variable, begin an animation, or play a sound.

They might even change the value of a variable that causes something to happen every frame for a little while.

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 reptilebeats · Jan 19, 2012 at 02:23 AM 0
Share

yh but say im using update would it be better to only check every frame if i push a button as im using touch it has to be update, and then if i do push this butten or gui then enable a seperate function with all the code in it

avatar image jahroy · Jan 19, 2012 at 02:32 AM 0
Share

Touch input works fine with Unity's GUI system.

When you draw a button with GUI.Button(), it detects touch input the same as mouse input.

If you're going to use Unity's GUI system, you have to use OnGUI. That's the only place where you can use the GUI functions. The OnGUI function actually gets called multiple times per frame, but that's O$$anonymous$$. That's how games work. There's no need to be worried about that as a performance hit (yet).

If you want to use Update (only once per frame) you will have to use GameObjects, GUITextures, and things like that.

I use Unity's GUI system (and OnGUI) for all my buttons, sliders, menus, etc... I have never done it the other way.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Advice about overdraw 1 Answer

Best way to create/design modular Player 2 Answers

Halo effect perfomance on mobile devices 1 Answer

Instantiate objects on iPhone affecting performance, strategy. 1 Answer

iPhone 4 game lags 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