Hi,
I have a lot of property attributes in my Unity project that derive from UnityEngine.PropertyAttribute, in order to make them work with the Unity custom drawers. Now, in order to make them work with NodeCanvas too, I see that I am required to subclass ParadoxNotion.Design.CustomDrawerAttribute. I wonder the rationale for this design decision. Wouldn’t it be better to make ParadoxNotion.Design.CustomDrawerAttribute simply an alias of UnityEngine.PropertyAttribute? That would allow interoperability. With the current design I need to duplicate all my attributes all over the place.
Unity’ object and attribute drawers work with SerializedProperty and SerializedProperty works only for things serialized on a UnityEngine.Object directly. The fields of Tasks and Tasks themselves (Actions/Coditions) as well as Nodes and pretty much everything else in NodeCanvas though, are not UnityEngine.Objects nor serialized on a UnityEngine.Object which is essential for better performance. As such SerializedProperty is irrelevant.
The short answer is that it is simply not possible and that is why a custom object/attributes drawers systems was made. I wish it was possible but sadly it’s not due to how Unity’s drawers work.
I think there’s a misunderstanding. I’m not saying that NodeCanvas should mess with the Unity attribute drawers, nor that they should converge on a single implementation of drawers. Drawers (both Unity’s and NodeCanvas’) are simply “attached” to attributes using C# reflection, but, from the a class-design perspective, attributes and drawers totally are unrelated. When Unity finds an attribute that derives from UnityEngine.PropertyAttribute, it looks for a Unity custom drawer attached to that using the UnityEditor.CustomPropertyDrawer attribute: if it finds a drawer it’s used, otherwise it’s not a problem and a default drawer is used. NodeCanvas does exactly the same, the only differences being that it checks if the attribute derives from ParadoxNotion.Design.CustomDrawerAttribute and that it looks for drawer classes derived from ParadoxNotion.Design.CustomDrawer. What would happen if UnityEngine.PropertyAttribute and ParadoxNotion.Design.CustomDrawerAttribute were the same class? Absolutely nothing. Both systems will still work and they would still both have all freedom to evolve in parallel without one interfering with each other, since the mechanism to find custom drawers are totally distinct. What changes for the end-user is that he/she can now have both drawer, a thing that was not possible before.
Author
Posts
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.