Example #1
0
 /// <summary>
 /// Attempts to load the class.
 /// </summary>
 /// <typeparam name="T">The type of class to load.</typeparam>
 /// <returns>Loaded UObject, or null if the class fails to load, or if the reference is not valid.</returns>
 public UClass TryLoadClass <T>() where T : UObject
 {
     if (ObjectPath.IsValid)
     {
         return(UObject.LoadClass <T>(null, ObjectPath.Path, null, ELoadFlags.None));
     }
     return(null);
 }
Example #2
0
        private static UClass FindOrLoadClass(string pathName, UClass baseClass)
        {
            // If there is no dot, add ".<object_name>_C"
            int packageDelimPos = pathName.IndexOf('.');

            if (packageDelimPos == -1)
            {
                int objectNameStart = pathName.LastIndexOf('/');
                if (objectNameStart != -1)
                {
                    pathName += "." + pathName.Substring(objectNameStart + 1) + "_C";
                }
            }
            UClass loadedClass = UObject.LoadClass(baseClass, null, pathName);

            if (loadedClass != null)
            {
                loadedClass.AddToRoot();
            }
            return(loadedClass);
        }