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

TypeDropdown Attribute #354

Open
apilola opened this issue Apr 17, 2023 · 6 comments
Open

TypeDropdown Attribute #354

apilola opened this issue Apr 17, 2023 · 6 comments

Comments

@apilola
Copy link

apilola commented Apr 17, 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;
}
@apilola
Copy link
Author

apilola commented Apr 20, 2023

Quck Note:
When switching between types, the property will automatically try to copy any fields from the original object to the destination object.

@antiNT2
Copy link

antiNT2 commented Apr 25, 2023

I am really interested in this !

@apilola
Copy link
Author

apilola commented Apr 25, 2023

What do you think? Should I submit a pull request with a preprocessor directive hiding it from older versions of unity?

@Vatredox
Copy link

Hey! What's the progress on this?

@dbrizov
Copy link
Owner

dbrizov commented Aug 15, 2023

I am about to merge a lot of pull requests next weekend, so I will include it :)

@apilola
Copy link
Author

apilola commented Aug 15, 2023

Formerly Created a PR here:
#368

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

No branches or pull requests

4 participants