• 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 schwertfisch · Jan 24, 2011 at 03:57 PM · cameraprefabactivatedeactivatepool

Activating & Deactivating prefabs from a prefab pool VS simply moving them on and off-camera (iOS)

I use a prefab pool, instead of instantiating and destroying prefabs of collectibles that get spawned in my game and collected (hence removed from view). The game is for iOS.

The prefabs pool is a group of prefabs that are off-camera and deactivated when the level is loaded.

Whenever a prefab is supposed to get spawned somewhere on the board, it gets activated, moved instantly on board (and on-camera). When my character collects it, it gets instantly moved off-camera and deactivated.

My pool consists of 50 prefabs (that's the maximum potential number of prefabs that might be used simultaneously on-camera).

Is there any use in my having them initially deactivated and activating-deactivating them as described above? Would having them activated all the time and just moving them on and off camera make any difference?

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 Jessy · Jan 24, 2011 at 05:02 PM

Activating is not a fast operation; you don't want to do that. You could move them, or you could just disable their components. You could also add event listeners only at the appropriate times.

Comment
Add comment · Show 3 · 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 schwertfisch · Jan 24, 2011 at 06:00 PM 0
Share

Thanks Jessy, but could you please be more specific? So moving the collectibles out of the viewable area when it has been collected, without deactivating it (using "gameObject.active = false;") is not using more resources (than if I had also deactivated it)? What component would it make sense deactivating (in order to spare resources I mean)? For example the collectible's "$$anonymous$$esh Renderer"?. I'll look into using event listeners as I don't yet know what they are.

avatar image Jessy · Jan 24, 2011 at 06:16 PM 0
Share

Right, moving a game object is no big deal unless it has a static collider - use kinematic rigidbodies if you need to move things with colliders. Disabling renderers is the most obvious, but it depends on your game, what you need to do. Unfortunately, I don't know that there are any tutorials showing you how to integrates events into Unity; I never see anyone else using them, but of course most of the code on these community sites is just snippets, not reflecting an interwoven scripting system. Here is a small example, anyway: http://answers.unity3d.com/questions/34045

avatar image schwertfisch · Jan 24, 2011 at 07:43 PM 0
Share

This was really helpful :)

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

No one has followed this question yet.

Related Questions

Using a pool of objects that will be spawned ONCAMERA and removed OFFCAMERA instead of INSTANTIATE & DESTROY (iOS) 1 Answer

How To Disable A Prefab? 2 Answers

Alternatives to iTweenPath for creating path for camera 2 Answers

AddComponent in script modifying Prefab Assets? 0 Answers

Howto set main.camera as a parent when main.camera itself is a child of a prefab 1 Answer

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