Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to clone several game objects in a way that clone properties of one can be adjusted to match all others in scene view

I asked How can I adjust shape/dimensions of one clone to affect all other clones in the scene view and the accepted answer was spot on. It could only clone one game object. I tried making some adjustments but the only solution I came up with was adding duplicate methods for additional objects. This doesn't work well when dealing with several game objects to be cloned.

How can I clone several unique game objects so that adjusting the components/properties of one clone would affect all other clones of that object in the scene view?

Please note that I don't want to achieve this at runtime and I don’t want to use prefabs. I am using this to help with creation of complex levels so the live update of clones being adjusted is very important.

Additionally, I also need a way to turn off the this repeated property/component replication on each clone, preferably with a button.

like image 417
NSSwift Avatar asked Jun 28 '18 18:06

NSSwift


People also ask

How do you select multiple game objects in Unity?

Instead seems the only way to do it is by holding CTRL, and clicking on each object individually.

What can you use to organize different game objects into groups inside the Hierarchy panel?

See in Glossary. You can use the Hierarchy window to sort and group the GameObjects you use in a Scene. When you add or remove GameObjects in the Scene view, you also add or remove them from the Hierarchy window.

What happens when you select a GameObject in the scene view?

The default hotkey to do this is Shift + F . When you press this with a Game Object selected the scene view's camera will zoom in and reposition itself to put the object in frame. As the object moves (for example while you play test your game) the scene view camera will continue to track the followed object.


1 Answers

I don’t want to use prefabs

The new prefab system in Unity is exactly what you need. It fits all of your requirements:

  • Clone several unique game objects

    The prefab system is made for cloning unique gameobjects. It even supports prefab nesting.

  • I don't want to achieve this at runtime

    Great, prefabs only update globally when you click the override button in the editor.

  • I need a way to turn off the this repeated property/component replication on each clone

    That's equivalent to unpacking the object (breaking the connection).

If you have a good reason to avoid using prefabs, you can always write a custom script that tracks changes in the properties you want to share, and updates all other objects immediately. You can make that script run in edit mode by adding the [ExecuteInEditMode] attribute to the class it's in, just don't forget to disable it when running the project. Again, I highly recommend using prefabs instead.

like image 158
Bip901 Avatar answered Sep 28 '22 18:09

Bip901