Quantcast
Channel: Answers for "Editor Wizard: Copy Existing Components to Another GameObject"
Browsing index pages (8 articles)
↧

Answer by Eran-Yaacobi

A better approach would be to use UnityEditorInternal namespace: UnityEditorInternal.ComponentUtility.CopyComponent(componentToCopy);...

View Article


Answer by DR9885

To add to that Reflection suggestion, if you are using private serialized variables, like me, you may want something more like this... foreach (FieldInfo info in...

View Article


Answer by Ranza

There's also a general solution for this problem: http://unitydevs.com/item/copypaste-component/

View Article

Answer by SimTex

Use reflection. Component new_component = gameObject.AddComponent(old_component.GetType()); foreach (FieldInfo f in old_component.GetType().GetFields()) { f.SetValue(new_component,...

View Article

Answer by Eran Yaacobi

A better approach would be to use UnityEditorInternal namespace: UnityEditorInternal.ComponentUtility.CopyComponent(componentToCopy);...

View Article


Answer by DR9885

To add to that Reflection suggestion, if you are using private serialized variables, like me, you may want something more like this... foreach (FieldInfo info in...

View Article

Answer by Ranza

There's also a general solution for this problem: http://unitydevs.com/item/copypaste-component/

View Article

Answer by SimTex

Use reflection. Component new_component = gameObject.AddComponent(old_component.GetType()); foreach (FieldInfo f in old_component.GetType().GetFields()) { f.SetValue(new_component,...

View Article

Browsing index pages (8 articles)


Latest Images