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

后端 未结 8 872
执念已碎
执念已碎 2020-12-11 15:29

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.

8条回答
  •  执笔经年
    2020-12-11 15:41

    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.

提交回复
热议问题