Custom inspector - How to serialize scene objects in ScriptableObject?
Hello,
I am writing a custom inspector for the artist in our team to design some simple animations (without using mecanim).
The basic setup is the following:
Animations are saved as ScriptableObjects. There is a class AnimationBase that inherits from ScriptableObject and different Animation classes that inherit from AnimationBase.
There is an AnimationSystem script that stores the animations for one gameobject. Animations can be added dynamically for different events (I got multiple MyAnimation[] to store those per event type). It also stores a string with the name of a ScriptableObject AnimationList. That ScriptableObject stores the filenames for all the used animations in lists of strings for the different animation event types.
Now I have an animation "EnableAnimation" (inheriting from AnimationBase and therefore a ScriptableObject) that should enable a gameobject. If I select a gameobject from the assets, the reference is saved in the EnableAnimation asset as expected. But when I select a gameobject from the scene, the EnableAnimation assets shows "Type mismatch" instead.
I think the problem is that I use a EnableAnimation asset but want to store information in the scene. Is it possible to store the ScriptableObject in the scene instead?
Another problem: How do you handle prefabs? The prefab should use a ScriptableObject asset but the prefab instance needs a "per scene" ScriptableObject?
And a last question: How do you store references to gameobjects that belong to the same prefab? For example I have a prefab "A" that has an AnimationSystem component and a child gamobject "B". With the default inspector I can select B as an gameobject in a script and apply that change to the prefab. If I select a different gameobject and try to apply, the prefab does not save reference. Is it possible to achieve this behaviour with scriptable objects and a custom inspector?
Thank you for your help!
Your answer
Follow this Question
Related Questions
EditorGUILayout.ObjectField on a ScriptableObject's inspector doesn't update properly 0 Answers
Unity Custom Editor: 1 True Bool Only Within A Group 1 Answer
No type in ObjectField created in uxml (UIElements) 3 Answers
Serialize child ScriptableObject asset values in parent ScriptableObject asset. 0 Answers