- Home /
Assigning an object to a SerializedProperty
Hi, I have a SerializedProperty in an editor class that is holding an AnimationClip and I would like to assign a new AnimationClip to it. I can't figure out how to do this as casting is throwing an error(Cannot implicitly convert type 'UnityEngine.animationClip' to 'UnityEditor.SerializedProperty') . I know its editable but I haven't been able to figure this out. Thanks in advance.
Answer by dylanfries · Jun 29, 2012 at 05:21 PM
Figured out my own answer from the Intro to Editor Scripting video at Unite 2011
you can use
clip = animation.FindPropertyRelative("animClip").objectReferenceValue; or animation.FindPropertyRelative("animClip").objectReferenceValue = clip;
Your answer
Follow this Question
Related Questions
Custom Inspector: Using SeralizedProperty changes the prefab values! 0 Answers
What would be the best way to go about loading and saving a Serializable object in JSON with Unity? 0 Answers
[SerializeField] Not Working Properly? 1 Answer
How to work with custom class (ScriptableObject) SerializedProperty? 1 Answer
How could I reset a modified serializedProperty in PlayMode runtime? 0 Answers