• 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 KarnEdge · Nov 30, 2013 at 05:21 AM · fpsmemoryframeratedontdestroyonloadcpu

What's better? Managers using DontDestroyOnLoad or keep one in each scene?

When it comes to making your game use less memory, reducing overall load times and keeping framerate up, do you have your Managers (Camera, Input, etc) use DontDestroyOnLoad and follow the player throughout the game OR do you put them in a prefab and toss it into every scene you make?

I ask because I realized some of my managers don't need to follow the player (no global variables, stats, etc), but need to be in every scene. I imagine that just making them DontDestroyOnLoad will reduce load time because you're loading them at the start of the game and never again, but maybe there is something behind DontDestroyOnLoad that makes it use more memory in the long run.

Anyone have an idea on this?

Keep in mind, I know I will still have to have a StateManager of some sort that will have to use DontDestroyOnLoad so I can keep track of stats, variables, etc.

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 Julien-Lynge · Nov 30, 2013 at 08:07 AM

@KarnEdge,

It's definitely good to be thinking about performance, but for what you're describing the difference is so negligible - a few ticks of time, probably only a few kB or MB of memory - that it really doesn't matter. It's much more important to go with whatever is going to make your job easier designing your game. If you have information that you need to keep between scenes, you could either use DontDestroyOnLoad or you could, for example, store the information in static variables so that any manager that's instantiated has access to them.

Personally, I like the second option, because it means that during development I can go directly into any scene without having to go through the main scene and instantiate my DontDestroyOnLoad object first.

Comment
Add comment · Show 1 · 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 KarnEdge · Nov 30, 2013 at 04:09 PM 0
Share

Thanks again @Julien.Lynge. I didn't see much on whether or not it mattered so thought I'd ask and put it out there.

Looks like I'll stick with the persistent managers and just have them load once on game start.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

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

Related Questions

Measure cpu and memory load in code? 3 Answers

What could possibly be wrong with this simplest-possible FPS counter? 1 Answer

How shot a bullet faster than the frame does? 2 Answers

Increasing Unity Frame Rate? 0 Answers

Frame rate drops when setting polygoncollider's path 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges