1
\$\begingroup\$

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?

Other things to take into account for solving the problem:

  • The custom inspector should work for prefabs, prefab instances and normal gameobjects. If possible prefab instances should be allowed to use the same animations as the prefab but change some values per scene.
  • 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 in the scene and try to apply, the prefab does not save the reference. If possible, this behaviour should be used too.

Thank you for your help!

\$\endgroup\$
  • \$\begingroup\$ If you mean that they are all things you need to take into account, you might want to clarify better. Perhaps think about how you can summarise your question better. I'd ask the one question (how to *use serialisation with game objects) and clarify your additional concerns in dot points. If you can split them up, there's nothing wrong with that. Separate questions make it more useful, especially if future users only have one of your questions to ask. \$\endgroup\$ – Gnemlock Nov 27 '16 at 21:04
  • \$\begingroup\$ @Gnemlock I've rephrased the question a little to take away the focus from the other two questions. I'll ask those in a seperate question instead if necessary. Thanks for the hints. \$\endgroup\$ – Superwayne Nov 27 '16 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.