NaughtyAttributes
NaughtyAttributes copied to clipboard
Added Typed Dropdown boiler plate
I've written this attribute using the SerializedReference API. It should work with pretty much any Non UnityEngine.Object derived type. Here is an example of it in action. I would submit a pull request for it, but it requires the project to be upgraded to 2021.2.
I could use a preprocessor directive to hide it, after I make my pull request. What are your thoughts?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AnimalTest : MonoBehaviour
{
[SerializeReference, TypeDropdown(typeof(Animal))] Animal MyPet;
}
[System.Serializable]
public class Animal
{
public string nickname = "Silly Billy";
}
public class Dog : Animal
{
public string Breed = "Golden Retriever";
}
public class Cat : Animal
{
public int lives = 9;
}