* Get container object based on UStruct */
| 156 | * Get container object based on UStruct |
| 157 | */ |
| 158 | UObjectBaseUtility* FLuaDebugValue::GetContainerObject(UStruct *Struct, void *ContainerPtr) |
| 159 | { |
| 160 | UObjectBaseUtility *ContainerObject = nullptr; |
| 161 | UClass *Class = Cast<UClass>(Struct); |
| 162 | if (Class) |
| 163 | { |
| 164 | if (Class->IsChildOf(UClass::StaticClass())) |
| 165 | { |
| 166 | // UClass |
| 167 | UClass *MetaClass = ContainerPtr ? (UClass*)ContainerPtr : Class; |
| 168 | if (MetaClass == UClass::StaticClass()) |
| 169 | { |
| 170 | ReadableValue = FString::Printf(TEXT("UClass*: 0x%p"), ContainerPtr); |
| 171 | } |
| 172 | else |
| 173 | { |
| 174 | ReadableValue = FString::Printf(TEXT("TSubclassOf<%s%s>: 0x%p"), MetaClass->GetPrefixCPP(), *MetaClass->GetName(), ContainerPtr); |
| 175 | } |
| 176 | } |
| 177 | else |
| 178 | { |
| 179 | // UObject |
| 180 | UObject *Object = (UObject*)ContainerPtr; |
| 181 | ContainerObject = Object; |
| 182 | ReadableValue = FString::Printf(TEXT("%s%s* (%s): 0x%p"), Class->GetPrefixCPP(), *Class->GetName(), Object ? *Object->GetName() : TEXT(""), ContainerPtr); |
| 183 | } |
| 184 | } |
| 185 | else |
| 186 | { |
| 187 | // UScriptStruct |
| 188 | UScriptStruct *ScriptStruct = Cast<UScriptStruct>(Struct); |
| 189 | if (ScriptStruct) |
| 190 | { |
| 191 | ReadableValue = FString::Printf(TEXT("F%s: 0x%p"), *ScriptStruct->GetName(), ContainerPtr); |
| 192 | } |
| 193 | else |
| 194 | { |
| 195 | ReadableValue = FString::Printf(TEXT("userdata (%s): 0x%p"), *FString::Printf(TEXT("%s%s"), Struct->GetPrefixCPP(), *Struct->GetName()), ContainerPtr); |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | return ContainerObject; |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * Build value based on a userdata |