@@ -63,10 +63,18 @@ int ExampleRef::get_id() const {
6363 return id;
6464}
6565
66+ void ExampleRef::_notification (int p_what) {
67+ if (p_what == NOTIFICATION_POSTINITIALIZE) {
68+ post_initialized = true ;
69+ }
70+ }
71+
6672void ExampleRef::_bind_methods () {
6773 ClassDB::bind_method (D_METHOD (" set_id" , " id" ), &ExampleRef::set_id);
6874 ClassDB::bind_method (D_METHOD (" get_id" ), &ExampleRef::get_id);
6975
76+ ClassDB::bind_method (D_METHOD (" was_post_initialized" ), &ExampleRef::was_post_initialized);
77+
7078 ADD_PROPERTY (PropertyInfo (Variant::INT, " id" ), " set_id" , " get_id" );
7179}
7280
@@ -220,6 +228,7 @@ void Example::_bind_methods() {
220228
221229 ClassDB::bind_method (D_METHOD (" def_args" , " a" , " b" ), &Example::def_args, DEFVAL (100 ), DEFVAL (200 ));
222230 ClassDB::bind_method (D_METHOD (" callable_bind" ), &Example::callable_bind);
231+ ClassDB::bind_method (D_METHOD (" test_post_initialize" ), &Example::test_post_initialize);
223232
224233 ClassDB::bind_static_method (" Example" , D_METHOD (" test_static" , " a" , " b" ), &Example::test_static);
225234 ClassDB::bind_static_method (" Example" , D_METHOD (" test_static2" ), &Example::test_static2);
@@ -597,6 +606,12 @@ Vector4 Example::get_v4() const {
597606 return Vector4 (1.2 , 3.4 , 5.6 , 7.8 );
598607}
599608
609+ bool Example::test_post_initialize () const {
610+ Ref<ExampleRef> new_example_ref;
611+ new_example_ref.instantiate ();
612+ return new_example_ref->was_post_initialized ();
613+ }
614+
600615// Virtual function override.
601616bool Example::_has_point (const Vector2 &point) const {
602617 Label *label = get_node<Label>(" Label" );
0 commit comments