Example #1
0
        /// <summary>
        /// Gets the UScriptStruct address for the given path (e.g. "/Script/CoreUObject.Guid")
        /// </summary>
        /// <param name="path">The path of the UScriptStruct</param>
        /// <returns>The address of the UScriptStruct for the given path</returns>
        public static IntPtr GetStructAddress(string path)
        {
            IntPtr address = NativeReflection.FindObject(Classes.UScriptStruct, IntPtr.Zero, path, false);

            if (address == IntPtr.Zero)
            {
                FName newPath = FLinkerLoad.FindNewNameForStruct(new FName(path));
                if (newPath != FName.None)
                {
                    address = NativeReflection.FindObject(Classes.UScriptStruct, IntPtr.Zero, newPath.ToString(), false);
                }
            }
            return(address);
        }
Example #2
0
        /// <summary>
        /// Gets the UStruct/UClass for the given path (e.g. "/Script/Engine.HitResult")
        /// </summary>
        /// <param name="path">The path of the object/struct</param>
        /// <returns>The UStruct/UClass for the given path</returns>
        public static UStruct GetStructOrClass(string path)
        {
            UStruct foundStruct = UObject.FindObject <UStruct>(UObject.AnyPackage, path);

            if (foundStruct == null)
            {
                // Look for redirectors
                FName newPath = FLinkerLoad.FindNewNameForStruct(new FName(path));
                if (newPath != FName.None)
                {
                    foundStruct = UObject.FindObject <UStruct>(UObject.AnyPackage, newPath.ToString());
                }

                if (foundStruct == null)
                {
                    newPath = FLinkerLoad.FindNewNameForClass(new FName(path), false);
                    if (newPath != FName.None)
                    {
                        foundStruct = UObject.FindObject <UClass>(UObject.AnyPackage, newPath.ToString());
                    }
                }
            }
            return(foundStruct);
        }