About using Addressable AssetReference in blackboards

NodeCanvas Forums Support About using Addressable AssetReference in blackboards

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #15410
    zsoik
    Participant

    I tried using AssetReference types in blackboards to easily specify addresses to prefabs that are automatically bundled by Addressables. Now, the problem is that NC can’t create a instance of AssetReference specializations (e.g. AssetReferenceGameObject) because they don’t exhibit a default constructor.

    Unity itself is perfectly fine with that and will happily create a AssetReferenceGameObject instance even though it has no default constructor, so I experimented a bit and added an “uninitialized object factory” to NC which creates an BB value instance even when there are no public default constructors available. The best way I found so far was FormatterServices.GetSafeUninitializedObject(t); but maybe there are better ways. I patched this inside ReflectedInspector.DirectFieldControl().

    So now I at least get a instance in the Blackboard but the property drawer for the asset reference does not work and is probably a whole different story.

    #15411
    Gavalakis
    Keymaster

    Hey,

    Using FormatterServices.GetSafeUninitializedObject for this is the best solution and patching it in ReflectedInspector.DirectFieldControl to make use of it with the “(null) Create” button is also the best place to add it 🙂

    GUI is indeed a whole different story, but you could write a custom ObjectDrawer for that and it should work fine.

    Join us on Discord: https://discord.gg/97q2Rjh

    #16205
    tournesol
    Participant

    Hello everyone,

    I am un-earthing this topic because usage of AssetReference in FlowCanvas and NodeCanvas is of utmost importance to us.

    I have been recommanding your software at multiple companies I worked at and right now we are hitting a wall because of Asset reference: as said at the beginning of this topic they don’t seem to be supported out of the box. And this is probably because asset reference is not a simple type.

    > GUI is indeed a whole different story, but you could write a custom ObjectDrawer for that and it should work fine.

    I tried my hand at that and looked at the PropertyDrawer called AssetReferenceDrawer in the addressable package for inspiration… it is a VERY complicated file. It doesn’t look like something canvas users can quickly patch together.

    So are you guys at paradox planning support anytime ?
    Did anyone eventually patch a solution together ? Could you share the code ?
    Even partial/buggy support would be appreciated.

    Anyway, thanks for the really great software guys !

    #16206
    zsoik
    Participant

    We ultimately didn’t bother and used strings for passing around addresses when required in nodecanvas. Yes, this is UX hell but for us it worked because we didn’t need that much of it in the end for our use-case.

    I still want NC to re-use drawers from the unity ecosystem, which would solve so much for custom types and UX.

    #16219
    tournesol
    Participant

    Thanks for the reply.
    Would love an official reply though. Aren’t addressables quite a commonly used tool ?

    We are gearing toward a solution with the asset becoming a pair of assets.

    The first one being a normal asset an therefore usable in nodes but holding the AssetReference field. This is unsatisfactory and might become quite un-managable by designers as the project grows.

    #16572
    tournesol
    Participant

    Uping this thread because we have multiple problems because of lack of support of objects that need a CustomPropertyDrawer such as adressables and FModUnity.EventReference.

    How could we use and FModEventReference with flow canvas. I mean FMod is a widely used tool how do we sort that out?

    I know you can use string and all but for a large project it is not acceptable.

    #16605
    Gavalakis
    Keymaster

    Hello,

    Supporting Unity’s CustomPropertyDrawers is unfortunately virtually impossible since Unity PropertyDrawers are tightly connected to Unity’s serialization system and can NOT be used without Unity’s serialization, whereas NodeCanvas is using a different serialization system to be able to handle more things than Unity was/is able to and for control over the serialization/deserialization process.

    With that said, please note that you can create custom object and property drawers for NodeCanvas in a similar manner to Unity’s drawers. (DOC LINK)

    Please let me know if creating custom object/property drawers is helpful in your case.

    Thanks!

    Join us on Discord: https://discord.gg/97q2Rjh

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.