Gist e8b15841a94b3df4ff4af56774e85370
✓ Published0🌍 Public
Aandybak
Last edited Aug 5, 2018
Created on Aug 5, 2018
This example shows a Unity Editor utility that copies and pastes serialized component values between different component types. It adds two menu commands, “Copy Serialized” and “Paste Serialized Values,” to the component context menu. The paste operation first checks if the source and destination components are the same type, using `EditorUtility.CopySerialized` for a direct copy. Otherwise, it iterates through the source’s `SerializedProperty` hierarchy, matching properties by name and type in the destination via `dest.FindProperty`, then copies values with `dest.CopyFromSerializedProperty` and applies changes with `ApplyModifiedProperties`. The code uses Unity’s `SerializedObject`, `SerializedProperty`, and `MenuItem` APIs.
AI-generated description