Hello Unity community, I’ve been using my own UI Animation system for long now, but I’ve never got to have an adequate inspector for it because I always get to a wall at some point when trying to:
The system is organized like this:
1- A Manager monobehaviour that controls the flow of the animations.
2- non-monobehaviour animations clases using inherintance. The base class is UIAnimation and then an example child class would be UIAnimation_Scale.
3- These UIAnimations can also have a base settings scriptable object, that when it is set, the rest of the parametters are ignored.
4- The Base Settings scriptable object, is just a holder for a UIAnimation class.
5- When declaring a public UIAnimation class, I need to be able to create/choose/add any of its child classes, not the parent class.
This is the BaseSettings class, that uses [SerializeReference] and a custom attribute from the package CareBoo to achieve it:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using CareBoo.Serially;
namespace UIAnimations
{
[CreateAssetMenu(fileName = "New UIAnimation Base Settings", menuName = "UIAnimations/Base Settings")]
public class UIAnimationBaseSettingData : ScriptableObject
{
[SerializeReference]
[ShowSerializeReference]
public UIAnimation baseUIAnimation;
}
}
However, I wonder if there is a better way to do this. This is also the way I show the UIAnimation inside the inspector when inside another monobehaviour. It looks like this:
I would like to have a toggle/bool to show/hide some values to not make the inspector crowded with unnecessary info. such as the read only parametters, and some advanced options. (I tried with the “Show Advanced Options” bool as seen there, but is not functional).
On the other hand, I’ve tried some [ShowIf()] attributes that I saw around, but they do not work well when showing UnityEvents, which take a lof of the space.
Custom Editor doesn’t seem like a solution because I would have to write a new one with new code over and over again for every new monobehaviour that contains a UIAnimation. Property Drawer would work… but with these 2 attributes I wrote (and need) it does not work. Attributes are the only thing somehow working as I intend it to, but not completely, as the ShowIf[()] attributes that I saw posted around by different people don’t work with UnityEvents at all.
I’m really lost and I don’t know where I went wrong with this. Should I completely reestructure my code? How?
Is there some magic solution I’m missing?
I can’t find any information whatsoever for any of these problems and ChatGPT is completely clueless too. Please, help me!