[BUG] Unable to select scriptable object function from Task Action node

NodeCanvas Forums Support [BUG] Unable to select scriptable object function from Task Action node

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #16177
    request
    Participant

    Issue:

    • I want to execute a function on a scriptable object via a Task Action node (Reflected -> Execute Function), but no functions show up in the dropdown list.
    • I found this bug while working on a Bound Dialog Tree

    Reproduction Steps:

    1. Create a scriptable object with some public function (example posted below)
    2. Add the scriptable object to Preferred Types list using the Preferred Types editor window (Tools -> ParadoxNotion -> NodeCanvas-> Preferred Types Editor. Click “Add New Type”, and select the scriptable object from step 1)
    3. Open a new dialog tree, right click, and select “Task Action”
    4. Click the new node, and click “Assign Action Task”. Select “Reflected -> Execute Function”
    5. Click “Select Method”, then select the Scriptable Object from step 1

    Expected behavior: A list of public functions show up in this list
    Current behavior: Only the “inherited” folder shows up in the list

     

    Am I using the wrong node to pick my functions or something? This is an issue I found during a completed project, so if it turns out there’s work to be done to fix this, please take your time. This doesn’t block any work on my end. Thanks!

     

    // Example scriptable object, cleaned up for clarity

    using UnityEngine;
    using UnityEngine.Events;

    [CreateAssetMenu(menuName = “Events/Save Manager Event Channel”)]
    public class SaveManagerEventChannel : ScriptableObject {
    // These are called in response to save/load/delete operations
    public UnityAction<SaveData> onLoad;
    public UnityAction onSave;

    public void OnSave() {
    if (onSave != null) {
    onSave.Invoke();
    }
    }
    public void OnLoad(SaveData loadedData) {
    // Raised for general state changes
    if (onLoad != null) {
    onLoad.Invoke(loadedData);
    }
    }
    }

    Attachments:
    You must be logged in to view attached files.
    #16179
    Gavalakis
    Keymaster

    Hello there,

    This is not actually a bug but rather a limitation. Right now, the Task agent parameter (where it usually reads “Self”), can only be a Component derived type. The Execute Function uses the agent parameter to set the target/instance of the method and since ScriptableObjects are not supported in that field, instance members are not shown, but rather only static members specifically for ScriptableObject types are shown.

    With that said, I do plan to change the Task agent parameter to work with ScriptableObjects in the future as well.

    I hope that clarifies what is going on and that it wasn’t that confusing 🙂

    Thanks!

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

    #16180
    request
    Participant

    Oh nice, marking a function as static makes it show up in the listing! I think I can hack together a singleton pattern for my use cases (I almost always just have a single instance of these event channel scriptable objects), so I likely have a workaround 🙂

    Out of curiosity, do you have a rough estimate for when you plan on working on this change?

    Thanks for the quick response!

     

    #16181
    Gavalakis
    Keymaster

    Hello again,

    You are welcome. Unfortunately I can’t promise on an estimate for this specific change since it requires a lot of refactoring on the core Task code, and it is not that high in priority, but it will eventually happen 🙂

    Thanks!

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

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