I would like to change/adjust the shape/dimensions of several cloned objects within the scene view by adjusting one. This object could be say a quad or a line renderer that needs to be extended. For example as one game objects line renderer is extended (using the mouse) in the scene view, all other clones are affected. I know that it's a lot simpler to adjust shape/dimensions of one object before cloning it, also this change can be made on a prefab and applied to all, but I need to see the dynamic changes as they happen to make my design process more effective. I would also like to turn this functionality on and off, when the need arises. Please see how I created my clones in this question.
Note that I don't want to achieve this at runtime.
Synchronize properties when modifications to the component are made. To work with the existing code-base, we'll also need to clone the modified object to ensure that it's not destroyed when we re-create the other objects.
So we want to know when any property on any component has been modified. With custom scripts it's trivial with
OnValidate
, but with a sealed component suchLineRenderer
it's a little trickier. Fortunately, since we're working with the Editor we have access to some of its core features.Specifically, we can hook into the Editor's
Undo.postprocessModifications
event to get a callback whenever modifications are made to the scene. This delegate will provide us with anUndoPropertyModification
array that will contain a list of modified component properties which we can use to synchronize the other objects viaEditorUtility.CopySerializedIfDifferent
.I've refactored the code a little, but for the most part, changes are minimal