66from contextlib import contextmanager
77from dataclasses import dataclass
88from functools import cache , wraps
9- from typing import Any
9+ from typing import Any , overload
1010
1111from unrealsdk import (
1212 __version_info__ ,
@@ -346,15 +346,23 @@ def _convert_struct_tuple_if_required(
346346_RE_NAME_SUFFIX = re .compile (r"^(.+)_\d+$" )
347347
348348
349- def _strip_name_property_suffix (name : str ) -> str :
349+ @overload
350+ def _strip_name_property_suffix (name : str ) -> str : ...
351+ @overload
352+ def _strip_name_property_suffix (name : tuple [str , ...]) -> tuple [str , ...]: ...
353+
354+
355+ def _strip_name_property_suffix (name : str | tuple [str , ...]) -> str | tuple [str , ...]:
350356 """
351357 Tries to strip the numeric suffix from a name property.
352358
353359 Args:
354- name: The input name.
360+ name: The input name(s) .
355361 Returns:
356- The stripped name.
362+ The stripped name(s) .
357363 """
364+ if isinstance (name , tuple ):
365+ return tuple (_strip_name_property_suffix (x ) for x in name )
358366 return match .group (1 ) if (match := _RE_NAME_SUFFIX .match (name )) else name
359367
360368
@@ -371,7 +379,7 @@ def _uobject_getattr(self: UObject, name: str) -> Any:
371379 case UInterfaceProperty ():
372380 return FScriptInterface (value )
373381 case UNameProperty ():
374- return _strip_name_property_suffix (value )
382+ return _strip_name_property_suffix (value ) # type: ignore
375383 case _:
376384 return value
377385
@@ -412,7 +420,7 @@ def _uobject_getattribute(self: UObject, name: str) -> Any:
412420 case "ObjectFlags" :
413421 return _ObjectFlagsProxy (self )
414422 case "Name" :
415- return _strip_name_property_suffix (_default_object_getattribute (self , "Name" ))
423+ return _strip_name_property_suffix (_default_object_getattribute (self , "Name" )) # type: ignore
416424 case _:
417425 return _default_object_getattribute (self , name )
418426
@@ -454,7 +462,7 @@ def _struct_getattr(self: WrappedStruct, name: str) -> Any:
454462 case UInterfaceProperty ():
455463 return FScriptInterface (value )
456464 case UNameProperty ():
457- return _strip_name_property_suffix (value )
465+ return _strip_name_property_suffix (value ) # type: ignore
458466 case _:
459467 return value
460468
@@ -487,8 +495,6 @@ def _array_getitem[T](self: WrappedArray[T], idx: int | slice) -> T | list[T]:
487495 return [_strip_name_property_suffix (x ) for x in val_seq ] # type: ignore
488496
489497 return _strip_name_property_suffix (value ) # type: ignore
490-
491- return _strip_name_property_suffix (value )
492498 case _:
493499 return value
494500
@@ -614,6 +620,14 @@ def _uobject_get_name(obj: UObject, /) -> str:
614620 return obj .Name
615621
616622
623+ def _uobject_get_object_name (obj : UObject , / ) -> str :
624+ current = obj
625+ output = f"{ obj .Name } "
626+ while current := current .Outer :
627+ output = f"{ current .Name } .{ output } "
628+ return output
629+
630+
617631@staticmethod
618632def _uobject_path_name (obj : UObject | None , / ) -> str :
619633 if obj is None :
@@ -657,6 +671,7 @@ def _unreal_method_compat_handler() -> Iterator[None]:
657671 UObject .GetAddress = UObject ._get_address # type: ignore
658672 UObject .GetFullName = _uobject_repr # type: ignore
659673 UObject .GetName = _uobject_get_name # type: ignore
674+ UObject .GetObjectName = _uobject_get_object_name # type: ignore
660675 UObject .PathName = _uobject_path_name # type: ignore
661676 UStructProperty .GetStruct = _ustructproperty_get_struct # type: ignore
662677 WrappedStruct .structType = _wrapped_struct_structType # type: ignore
@@ -680,6 +695,7 @@ def _unreal_method_compat_handler() -> Iterator[None]:
680695 del UObject .GetAddress # type: ignore
681696 del UObject .GetFullName # type: ignore
682697 del UObject .GetName # type: ignore
698+ del UObject .GetObjectName # type: ignore
683699 del UObject .PathName # type: ignore
684700 del UStructProperty .GetStruct # type: ignore
685701 del WrappedStruct .structType # type: ignore
0 commit comments