Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Typed Dropdown boiler plate #368

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

apilola
Copy link

@apilola apilola commented Aug 15, 2023

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?

TypeDropdown

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;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant