Project now should be accessed from github page. GitHub repository :
https://github.com/TextusGames/UnitySerializedReferenceUI
I have made generic [SerializeReference] UI library which allows assigning serialized reference to any child type available in the whole project even in different assemblies (via TypeChache).
There is 3 way you can use it
- Add [SerialzeReference] [SerialzeReferenceButton] on top of field
and there button will be drawn that allows to select child types. - Add [SerialzeReference] [SerialzeReferenceMenu] on top of field
and you can press middle mouse button in order to assign child types - Via custom property drawer. Use simple method to show automatic menu.
Example of use
[SerializeReference]
[SerializeReferenceButton]
public List<AnimalBase> ButtonAnimals = new List<AnimalBase>();
It proves that collecting all child types, making menu out of them, selecting and assigning it to serialized is possible.
I hope unity will adopt this in the future or make something similar because it is possible and people need this UI functionality for [SerializeReference].
Edited. 02.13.20.
Supports interfaces.
Excludes types derived from UnityEngine.Object.
Excluded abstract classes.
Moved to package.
Edited 02.28.20
Major clean up and refactoring
Core is now just 2 small files
But everething else is bigget becouse it contains type restriction classes.
Added Type restrictions (built in ones like include types, include interfaces, exclude types, exclude interfaces)
Adde type substring restriction( But search is not imblemented in UI yet)
Added ability to combine multiple restriction attributes.
Added ability to write params of restricted types in new restriction attributes.
Changed example.
Edited 02.29.20
GreatlySimplified type restriction code.
There are now 2 built in atributes for restriction that can take both type or interface type as a parameter.
[Header("Field with multiple restrictions(Include, Exclude - Type, Interface")]
[SerializeReference]
[SerializeReferenceButton]
[SerializeReferenceUIRestrictionIncludeTypes(typeof(MammalBase), typeof(IFish))]
[SerializeReferenceUIRestrictionExcludeTypes(typeof(RedCat), typeof(IDog), typeof(BlackFish))]
public IAnimal AnimalWithRestriction = default;
Edited 05.16.20
Project clean up.
Github repository was created for this project.
https://github.com/TextusGames/UnitySerializedReferenceUI
Uploaded new package.
But from now on new versions should be downloaded from github.
Package is in attachement.
5393394–622684–Textus.SerializedReferenceUI_1.0_Preview.unitypackage (12.6 KB)