I am using the Addressables package of Unity.
I am trying to restrict an AssetReference type in the Unity inspector to a specific type. Currently a user can assign any Unity object to an AssetReference, but I would like to guide the user to assign the correct types to the correct variables and (if possible) filter the assets type list to include only the assignable types when the user click on the drop-down arrow
According to the Unity documentation https://docs.unity3d.com/Packages/[email protected]/api/UnityEngine.ResourceManagement.Util.SerializedTypeRestrictionAttribute.html
it seems like there is some sort of annotation available. The documentation is very limited and I have tried:
[UnityEngine.ResourceManagement.Util.SerializedTypeRestrictionAttribute(type=typeof(PlayerMaster))]
public UnityEngine.AddressableAssets.AssetReference playerMaster;
but it made no difference.
I also tried to create my own AssetReference type:
[Serializable]
public class Reference : UnityEngine.AddressableAssets.AssetReferenceT<PlayerMaster>, UnityEngine.AddressableAssets.IKeyEvaluator
{
public Reference(string guid) : base(guid)
{
}
}
but with this new type I cannot select anything!
The following code snippet at least seems to restrict the list to GameObjects which is an improvement, but the user can still assign the wrong GameObjects easily. I was hoping for a more strict filter, but if it is not possible I will settle with:
public UnityEngine.AddressableAssets.AssetReferenceGameObject playerMaster;