Search Unity

Question Calling Application.dataPath from Definition Method of an Unit

Discussion in 'Visual Scripting' started by SaschaMoos19997, Nov 3, 2022.

  1. SaschaMoos19997

    SaschaMoos19997

    Joined:
    Sep 1, 2021
    Posts:
    3
    I would like to call "Application.dataPath" inside the "Definition", because i set the Succession according to it.

    protected override void Definition()
    {
    string test = Path.Combine(Application.dataPath, someFileName);
    if(File.Exists(test))
    {
    Succession(inputTrigger, outputTriggerA);
    }
    else
    {
    Succession(inputTrigger, outputTriggerB);
    }
    }

    When i do that i receive

    Failed to define CustomNode#bf5ca...:
    UnityEngine.UnityException: get_dataPath is not allowed to be called during serialization, call it from OnEnable instead. Called from ScriptableObject 'ScriptGraphAsset'.
    See "Script Serialization" page in the Unity Manual for further details.


    What possible workarounds are there?
     
    Last edited: Nov 5, 2022