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:
Create a scriptable object with some public function (example posted below)
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)
Open a new dialog tree, right click, and select “Task Action”
Click the new node, and click “Assign Action Task”. Select “Reflected -> Execute Function”
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);
}
}
}
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 🙂
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?
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
Author
Posts
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.