Exemplo n.º 1
0
 public UClass AsClass()
 {
     if (!string.IsNullOrEmpty(Value))
     {
         return(UObject.FindObject <UClass>(ObjectOuter.AnyPackage, Value));
     }
     return(null);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the asset UObject if it is loaded or loads the asset if it is unloaded then returns the result
        /// </summary>
        /// <returns></returns>
        public UObject GetAsset()
        {
            if (!IsValid)
            {
                return(null);
            }

            UObject asset = UObject.FindObject <UObject>(null, ObjectPath.ToString());

            if (asset == null)
            {
                asset = UObject.LoadObject <UObject>(null, ObjectPath.ToString());
            }
            return(asset);
        }
Exemplo n.º 3
0
        private static void CheckFoundViaRedirect(UObject obj, string pathName, string objectToFind)
        {
            UObjectRedirector redir = UObject.FindObject <UObjectRedirector>(ObjectOuter.AnyPackage, pathName);

            if (redir != null && redir.DestinationObject == obj)
            {
                string             str = obj.GetFullName().Replace(" ", "'") + "'";
                FObjectInitializer currentInitializer = FUObjectThreadContext.TopInitializer();
                UClass             unrealClass        = currentInitializer.IsNull ? null : currentInitializer.GetClass();

                string message = string.Format("CDO Constructor ({0}): Followed redirector ({1}), change code to new path ({2])\n",
                                               (unrealClass != null ? unrealClass.GetName() : "Unknown"), objectToFind, str);
                Log(ELogVerbosity.Warning, message);
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }