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 coffiarts · Jul 30, 2013 at 05:36 PM · animationperformancelightparticle systemonbecamevisible

Is it reasonable to use OnBecameVisible for controlling animations, lights and particle systems?

Hi everybody,

I want to reduce performance overhead in my game. From the docs I've learned about using OnBecameVisible and OnBecameInvisible for enabling/disabling scripted behaviour depending on visibility.

In the examples, these functions are used to enable/disable whole scripts, e.g. like this:

 function OnBecameVisible()
 {
   enabled = true;
 }
 
 function OnBecameInvisible()
 {
   enabled = false;
 }
 
 

This sounds quite clear and reasonable to me.

However, the most performance consuming parts of my game objects are not the scripts, but rather

  • animations

  • lights

  • particle emitters

So I've scripted my OnBecameVisible/OnBecameInvisible methods in a way that they enable/disable these components (which seems to work fine).

My question however is: Does this make sense? Is it necessary at all? Or does the game engine optimize the rendering of such components by itself in a way that invisible animations etc. are suspended automatically whenever no camera can see them? Am I doing something completely redundant here?

I found some discussion about animations here: http://answers.unity3d.com/questions/48683/Animations--Animate-only-when-visible.html. But this seems to relate to an older Unity version, because in my Animation component, there doesn't seem to be an option called "Animate only if visible" anymore. Instead, we now have the "culling type" option, but according to my understanding of the documentation (Animation Reference) this seems to be meant for something different.

Thanks for any hints!

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 jacobschellenberg · Jul 30, 2013 at 05:46 PM

It is a reasonable option, but keep in mind the GameObject will not update during the time it is off camera view. Therefore, if say that GameObject needs to do something during update, it will not happen. Instead, you could give the GameObject an "Off" state which is activated when no longer in camera view. Allowing it to continue to run Updates if needed, but is not actually disabled.

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 coffiarts · Jul 30, 2013 at 06:57 PM 0
Share

Thanks for your answer. Especially the last thing is a good point! I am aware of the Update pausing, and in my case it doesn't matter (because my objects are not moving, they simply need to run animations and receive RPC calls). But it's a good idea to use some boolean on/off flag in case one should have to still run Update() in invisible state!

avatar image jacobschellenberg · Jul 30, 2013 at 07:07 PM 0
Share

Glad I could help :)

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

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

Related Questions

Is 2d animation better for performance over particle system? 1 Answer

Adding animation clips via script 2 Answers

What's best (performant) way to animate light bulbs? 1 Answer

Eyes animation texture problem 0 Answers

How to animate a color value? 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