Giter Club home page Giter Club logo

Comments (2)

AThousandShips avatar AThousandShips commented on July 3, 2024 2

This is essentially a duplicate of:

from godot.

raulsntos avatar raulsntos commented on July 3, 2024

It looks like ClassDB can't find the method with the provided hash.

When the ResourceLoader::load_threaded_get_status method is bound, the computed hash is 4137685479. This is the same hash that C# is using to retrieve the method. However, when C# tries to retrieve this method the computed hash is 1185939122, so it doesn't match.

Why is the computed hash different? The default value for the progress argument is an empty array ([]), but when C# tries to retrieve this method, the default value was a non-empty array ([1]).

ClassDB::bind_method(D_METHOD("load_threaded_get_status", "path", "progress"), &ResourceLoader::load_threaded_get_status, DEFVAL(Array()));

It looks like when the argument is not provided, the method modifies the default array:

godot/core/core_bind.cpp

Lines 55 to 61 in 96a386f

ResourceLoader::ThreadLoadStatus ResourceLoader::load_threaded_get_status(const String &p_path, Array r_progress) {
float progress = 0;
::ResourceLoader::ThreadLoadStatus tls = ::ResourceLoader::load_threaded_get_status(p_path, &progress);
r_progress.resize(1);
r_progress[0] = progress;
return (ThreadLoadStatus)tls;
}

In your workaround, since C# retrieves the method before it's called (and thus before the default array is modified), ClassDB is able to find the method and C# caches it.

Another way to workaround this would be to provide a value for the progress argument:

diff --git a/ThreadedLoadFromGDScript.gd b/ThreadedLoadFromGDScript.gd
index 8fc1c1c..094927c 100644
--- a/ThreadedLoadFromGDScript.gd
+++ b/ThreadedLoadFromGDScript.gd
@@ -17,7 +17,7 @@ func _process(delta):
 		_threaded_process()
 
 func _threaded_process():
-	var load_status = ResourceLoader.load_threaded_get_status(scene_path)
+	var load_status = ResourceLoader.load_threaded_get_status(scene_path, [])
 	if load_status == ResourceLoader.THREAD_LOAD_LOADED:
 		var node = ResourceLoader.load_threaded_get(scene_path).instantiate()
 		add_child(node)

from godot.

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.