#Extend editor to select object's which implement some interface.
1 messages · Page 1 of 1 (latest)
How would i be able to conform this?
Seems like this is only inherited to unity objects, which neither my struct, nor SerializedProperty/ Object are, so i'm not able to log this or something.
I mean the Editor itself EventChannelEditorBase
So in OnEnable() just do hideFlags = HideFlags.None;
Oh, guess i'm stupid again sorry 😄
But it worked indeed, was set to HideAndDontSave. So atleast they are editable now, but unfortunatly the interface still displays only a label.
Okay, that is what I thought. But you don't want to leave it like that, the flags are there for a good reason. Instead you want to simply remove the NotEditable flag https://docs.unity3d.com/ScriptReference/HideFlags.NotEditable.html
(You can google to see how to remove certain values from a flag enum)
What do you mean " unfortunatly the interface still displays only a label"?
Oh I thnk I know what you mean
It is because the field is [SerializeReference] (I assume). If you don't assign anything to it, it will be null
Unlike when using [SerializeField]
The reason is because it is serialized as a reference instead of a value. And references can be null nut values can't be.
Okay, i'll change that.
Currently it looks like this, but your assumption was right, and i guess the conclusion also makes sense 🙂 :
If you don't assign anything to it, it will be null
That's something i'm not able to figure out. I don't know which exact type it would be at develepment time, so my thought was i'd have to get some "Object picker field" in first place, and when one was picked i could get the type there, if it even still matters at that point.
Ahh yeah, sadly Unity doesn't provide a picker for SerializeReference types by default. You can either get a general purpose one from github. Or make one yourself for your use case.
If you make it yourself, you can use the TypeCache class to get all the types derived from the type. And then just put them in a dropdown. When you select one you just create a instance of the type and assign it to the serialize property.
Okay, i'll look them up to and see if i can find something that fits 🙂
TypeCache also looks interesting. Thanks for those tips and the time you invested here 🙂