File tree 2 files changed +14
-0
lines changed
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -209,9 +209,12 @@ impl<T: GodotClass> Gd<T> {
209
209
210
210
/// ⚠️ Looks up the given instance ID and returns the associated object.
211
211
///
212
+ /// Corresponds to Godot's global function `instance_from_id()`.
213
+ ///
212
214
/// # Panics
213
215
/// If no such instance ID is registered, or if the dynamic type of the object behind that instance ID
214
216
/// is not compatible with `T`.
217
+ #[ doc( alias = "instance_from_id" ) ]
215
218
pub fn from_instance_id ( instance_id : InstanceId ) -> Self {
216
219
Self :: try_from_instance_id ( instance_id) . unwrap_or_else ( |err| {
217
220
panic ! (
Original file line number Diff line number Diff line change @@ -58,6 +58,17 @@ impl InstanceId {
58
58
self . to_u64 ( ) & ( 1u64 << 63 ) != 0
59
59
}
60
60
61
+ /// Dynamically checks if the instance behind the ID exists.
62
+ ///
63
+ /// Rather slow, involves engine round-trip plus object DB lookup. If you need the object, use
64
+ /// [`Gd::from_instance_id()`][crate::obj::Gd::from_instance_id] instead.
65
+ ///
66
+ /// This corresponds to Godot's global function `is_instance_id_valid()`.
67
+ #[ doc( alias = "is_instance_id_valid" ) ]
68
+ pub fn lookup_validity ( self ) -> bool {
69
+ crate :: gen:: utilities:: is_instance_id_valid ( self . to_i64 ( ) )
70
+ }
71
+
61
72
// Private: see rationale above
62
73
pub ( crate ) fn to_u64 ( self ) -> u64 {
63
74
self . value . get ( )
You can’t perform that action at this time.
0 commit comments