#Extend editor to select object's which implement some interface.

1 messages · Page 1 of 1 (latest)

proven portal
#

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.

wide summit
#

So in OnEnable() just do hideFlags = HideFlags.None;

proven portal
wide summit
#

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.

proven portal
# wide summit Okay, that is what I thought. But you don't want to leave it like that, the flag...

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.

wide summit
# proven portal Okay, i'll change that. Currently it looks like this, but your assumption was ri...

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.

proven portal