From 20c4e843b09b7263078c23ec635198feae03c227 Mon Sep 17 00:00:00 2001 From: David Snopek Date: Wed, 29 Nov 2023 11:50:48 -0600 Subject: Send NOTIFICATION_POSTINITIALIZE to extension classes --- test/src/example.cpp | 15 +++++++++++++++ test/src/example.h | 7 +++++++ 2 files changed, 22 insertions(+) (limited to 'test/src') diff --git a/test/src/example.cpp b/test/src/example.cpp index 2b8bef6..5372d70 100644 --- a/test/src/example.cpp +++ b/test/src/example.cpp @@ -63,10 +63,18 @@ int ExampleRef::get_id() const { return id; } +void ExampleRef::_notification(int p_what) { + if (p_what == NOTIFICATION_POSTINITIALIZE) { + post_initialized = true; + } +} + void ExampleRef::_bind_methods() { ClassDB::bind_method(D_METHOD("set_id", "id"), &ExampleRef::set_id); ClassDB::bind_method(D_METHOD("get_id"), &ExampleRef::get_id); + ClassDB::bind_method(D_METHOD("was_post_initialized"), &ExampleRef::was_post_initialized); + ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id"); } @@ -220,6 +228,7 @@ void Example::_bind_methods() { ClassDB::bind_method(D_METHOD("def_args", "a", "b"), &Example::def_args, DEFVAL(100), DEFVAL(200)); ClassDB::bind_method(D_METHOD("callable_bind"), &Example::callable_bind); + ClassDB::bind_method(D_METHOD("test_post_initialize"), &Example::test_post_initialize); ClassDB::bind_static_method("Example", D_METHOD("test_static", "a", "b"), &Example::test_static); ClassDB::bind_static_method("Example", D_METHOD("test_static2"), &Example::test_static2); @@ -597,6 +606,12 @@ Vector4 Example::get_v4() const { return Vector4(1.2, 3.4, 5.6, 7.8); } +bool Example::test_post_initialize() const { + Ref new_example_ref; + new_example_ref.instantiate(); + return new_example_ref->was_post_initialized(); +} + // Virtual function override. bool Example::_has_point(const Vector2 &point) const { Label *label = get_node