mirror of
https://github.com/godotengine/godot-cpp.git
synced 2026-01-01 05:48:37 +03:00
Allow GDExtensions to register virtual methods and call them on scripts
This commit is contained in:
5
test/project/example.gd
Normal file
5
test/project/example.gd
Normal file
@@ -0,0 +1,5 @@
|
||||
extends Example
|
||||
|
||||
func _do_something_virtual(p_name, p_value):
|
||||
custom_signal.emit(p_name, p_value)
|
||||
return "Implemented"
|
||||
@@ -241,6 +241,10 @@ func _ready():
|
||||
assert_equal(new_example_ref.was_post_initialized(), true)
|
||||
assert_equal(example.test_post_initialize(), true)
|
||||
|
||||
# Test a virtual method defined in GDExtension and implemented in script.
|
||||
assert_equal(example.test_virtual_implemented_in_script("Virtual", 939), "Implemented")
|
||||
assert_equal(custom_signal_emitted, ["Virtual", 939])
|
||||
|
||||
exit_with_status()
|
||||
|
||||
func _on_Example_custom_signal(signal_name, value):
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dmx2xuigcpvt4"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dmx2xuigcpvt4"]
|
||||
|
||||
[ext_resource type="Script" path="res://main.gd" id="1_qesh5"]
|
||||
[ext_resource type="Script" path="res://example.gd" id="2_jju25"]
|
||||
|
||||
[node name="Node" type="Node"]
|
||||
script = ExtResource("1_qesh5")
|
||||
|
||||
[node name="Example" type="Example" parent="."]
|
||||
script = ExtResource("2_jju25")
|
||||
|
||||
[node name="ExampleMin" type="ExampleMin" parent="Example"]
|
||||
layout_mode = 0
|
||||
|
||||
Reference in New Issue
Block a user