Пример #1
0
        private void MoveToTransientPackage(IntPtr obj)
        {
            // Copy of UObjectBase.cpp UClassCompiledInDefer

            // Check if rooted?
            Native_UObjectBaseUtility.RemoveFromRoot(obj);
            Native_UObjectBaseUtility.ClearFlags(obj, EObjectFlags.Standalone | EObjectFlags.Public);

            IntPtr defaultObject = Native_UClass.GetDefaultObject(obj, false);

            if (defaultObject != IntPtr.Zero)
            {
                // Check if rooted?
                Native_UObjectBaseUtility.RemoveFromRoot(defaultObject);
                Native_UObjectBaseUtility.ClearFlags(defaultObject, EObjectFlags.Standalone | EObjectFlags.Public);
            }

            FName oldClassRename = NativeReflection.MakeUniqueObjectName(NativeReflection.GetTransientPackage(),
                                                                         Native_UObjectBase.GetClass(obj), new FName("USharpHotReload_" + Native_UObjectBase.GetFName(obj)));

            using (FStringUnsafe oldClassRenameUnsafe = new FStringUnsafe(oldClassRename.ToString()))
            {
                Native_UObject.Rename(obj, ref oldClassRenameUnsafe.Array, NativeReflection.GetTransientPackage(), ERenameFlags.None);
            }

            Native_UObjectBaseUtility.SetFlags(obj, EObjectFlags.Transient);
            Native_UObjectBaseUtility.AddToRoot(obj);
        }
Пример #2
0
 public static IntPtr FindField(IntPtr unrealStruct, FName fieldName)
 {
     if (fieldName == FName.None)
     {
         return(IntPtr.Zero);
     }
     return(FindField(unrealStruct, fieldName.ToString()));
 }
Пример #3
0
        /// <summary>
        /// Returns string version of asset path, including both package and asset but not subobject
        /// </summary>
        /// <returns></returns>
        public string GetAssetPathString()
        {
            if (AssetPathName == FName.None)
            {
                return(string.Empty);
            }

            return(assetPathName.ToString());
        }
Пример #4
0
        /// <summary>
        /// Gets the UClass for the given path (e.g. "/Script/Engine.Actor")
        /// </summary>
        /// <param name="path">The path of the object/class</param>
        /// <returns>The UClass for the given path</returns>
        public static UClass GetClass(string path)
        {
            UClass foundClass = UObject.FindObject <UClass>(UObject.AnyPackage, path);

            if (foundClass == null)
            {
                // Look for class redirectors
                FName newPath = FLinkerLoad.FindNewNameForClass(new FName(path), false);

                if (newPath != FName.None)
                {
                    foundClass = UObject.FindObject <UClass>(UObject.AnyPackage, newPath.ToString());
                }
            }
            return(foundClass);
        }
Пример #5
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);
        }
Пример #6
0
        /// <summary>
        /// Gets the UClass address for the given path (e.g. "/Script/Engine.Actor")
        /// </summary>
        /// <param name="path">The path of the object/class</param>
        /// <returns>The UClass address</returns>
        public static IntPtr GetClassAddress(string path)
        {
            IntPtr address = NativeReflection.FindObject(Classes.UClass, IntPtr.Zero, path, false);

            if (address == IntPtr.Zero)
            {
                FName newPath = FLinkerLoad.FindNewNameForClass(new FName(path), false);
                if (newPath != FName.None)
                {
                    address = NativeReflection.FindObject(Classes.UClass, IntPtr.Zero, newPath.ToString(), false);
                }
            }
            return(address);
        }
Пример #7
0
 public void AppendLine(FName line)
 {
     AppendLine(line.ToString());
 }