Coder Social home page Coder Social logo

Comments (5)

MohHeader avatar MohHeader commented on May 20, 2024

Also wanted to mention that ( in case it would help )

that my Calculate () in Custom Node is just returning true

public override bool Calculate () {
    return true;
}

from node_editor_framework.

Seneral avatar Seneral commented on May 20, 2024

Thanks for the feedback:)

I found that the file path preparation (that makes your input compatible with either AssetDatabase or Resources) and actual loading are inconsistent - the one uses AssetDatabase in playmode, the other Resources. But in a built, it should work.

So, please open ResourceManager.cs in Utility and check if replacing these first three functions works:

#region Common Resource Loading

/// <summary>
/// Prepares the path; At Runtime, it will return path relative to Resources, in editor, it will return the assets relative to Assets. Takes any path.
/// </summary>
public static string PreparePath (string path) 
{
    path = path.Replace (Application.dataPath, "Assets");
    #if UNITY_EDITOR
    if (!Application.isPlaying)
    {
        if (!path.StartsWith ("Assets/"))
            path = _ResourcePath + path;
        return path;
    }
    #endif
    if (path.Contains ("Resources"))
        path = path.Substring (path.LastIndexOf ("Resources") + 10);
    return path.Substring (0, path.LastIndexOf ('.'));
}

/// <summary>
/// Loads a resource in the resources folder in both the editor and at runtime. 
/// Path can be global, relative to the assets folder or, if used at runtime only, any subfolder, but has to be in a Resource folder to be loaded at runtime
/// </summary>
public static T[] LoadResources<T> (string path) where T : UnityEngine.Object
{
    path = PreparePath (path);
#if UNITY_EDITOR // In the editor
    if (!Application.isPlaying)
        return UnityEditor.AssetDatabase.LoadAllAssetsAtPath (path).OfType<T> ().ToArray ();
#endif
    throw new NotImplementedException ("Currently it is not possible to load subAssets at runtime!");
    // return UnityEngine.Resources.LoadAll<T> (path);
}

/// <summary>
/// Loads a resource in the resources folder in both the editor and at runtime
/// Path can be global, relative to the assets folder or, if used at runtime only, any subfolder, but has to be in a Resource folder to be loaded at runtime
/// </summary>
public static T LoadResource<T> (string path) where T : UnityEngine.Object
{
    path = PreparePath (path);
#if UNITY_EDITOR // In the editor
    if (!Application.isPlaying)
        return UnityEditor.AssetDatabase.LoadAssetAtPath<T> (path);
#endif
    return UnityEngine.Resources.Load<T> (path);
}

#endregion

Also, loading EditorStates will not work either, as currently they have to be fetched from the subAssets of the file and these are not accessible through Resources:/

Seneral

from node_editor_framework.

MohHeader avatar MohHeader commented on May 20, 2024

Thanks for your response,

Hmmmm,
I am not sure,But now both Built version and Play in Editor raise the exception :

    throw new NotImplementedException ("Currently it is not possible to load subAssets at runtime!");

I think that is what you want to say, I can't use the Nodes in Runtime ?

I am really sorry, But I am totally confused, because I thought that the CanvasNode is ready to be used in Runtime.

Please excuse my ignorance, but if it is not available in run-time
Then it is still in experiment phase ?
( i.e. I can't use it's results yet in game logic ,, true ? )

Thanks

from node_editor_framework.

Seneral avatar Seneral commented on May 20, 2024

You can use it, but whatever method your using, you can't yet load editor states. So you need to make sure nothing will trigger Resources.LoadResources ;) Because that requires subAssets to work and this is not possible at runtime...
It is possible to fix that by simply make the canvas reference the editor states, because the canvas is easily retrievable as it's the main asset in the file.

from node_editor_framework.

Seneral avatar Seneral commented on May 20, 2024

This is fixed in the newest commit 23c875b to the develop branch:)
Please read notes, they will tell you what works and what not at runtime!

from node_editor_framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.