public void SetClass(UClass unrealClass) { if (unrealClass != null && !unrealClass.IsA <T>()) { throw new Exception("TAssetClass - tried to set class with the wrong target class type. Expected:" + typeof(T) + " Actual:" + UClass.GetType(unrealClass.Address)); } softObject.Value = unrealClass; }
public void SetClass(UClass unrealClass) { if (unrealClass != null) { if (!unrealClass.IsA <T>()) { throw new Exception("TSubclassOf - tried to set class with the wrong target class type. Expected:" + typeof(T) + " Actual:" + UClass.GetType(unrealClass.Address)); } subclassOf.ClassAddress = unrealClass.Address; } else { subclassOf.ClassAddress = IntPtr.Zero; } }
public void SetClass(UClass unrealClass) { if (unrealClass != null) { if (!unrealClass.ImplementsInterface <T>()) { throw new Exception("TSubclassOfInterface - the given class doesn't implement the interface: '" + typeof(T) + "' class:" + UClass.GetType(unrealClass.Address)); } subclassOf.ClassAddress = unrealClass.Address; } else { subclassOf.ClassAddress = IntPtr.Zero; } }
internal static void GenerateCode(string[] args) { try { bool invalidArgs = false; if (args.Length > 0) { CodeGenerator codeGenerator = null; switch (args[0]) { /*case "blueprints": * AssetLoadMode loadMode = AssetLoadMode.Game; * bool clearAssetCache = false; * bool skipLevels = false; * if (args.Length > 1) * { * switch (args[1]) * { * case "game": * loadMode = CodeGenerator.AssetLoadMode.Game; * break; * case "gameplugins": * loadMode = CodeGenerator.AssetLoadMode.GamePlugins; * break; * case "engine": * loadMode = CodeGenerator.AssetLoadMode.Engine; * break; * case "engineplugins": * loadMode = CodeGenerator.AssetLoadMode.EnginePlugins; * break; * case "all": * loadMode = CodeGenerator.AssetLoadMode.All; * break; * } * } * if (args.Length > 2) * { * bool.TryParse(args[2], out clearAssetCache); * } * if (args.Length > 3) * { * bool.TryParse(args[3], out skipLevels); * } * codeGenerator = new CodeGenerator(); * codeGenerator.GenerateCodeForBlueprints(loadMode, clearAssetCache, skipLevels); * break;*/ case "game": codeGenerator = new CodeGenerator(); codeGenerator.GenerateCodeForModules(new UnrealModuleType[] { UnrealModuleType.Game }); break; case "gameplugins": codeGenerator = new CodeGenerator(); codeGenerator.GenerateCodeForModules(new UnrealModuleType[] { UnrealModuleType.GamePlugin }); break; case "modules": // Engine modules (whitelisted) codeGenerator = new CodeGenerator(); //codeGenerator.Settings.ExportMode = CodeGeneratorSettings.CodeExportMode.All; //codeGenerator.Settings.ExportAllFunctions = true; //codeGenerator.Settings.ExportAllProperties = true; string whitelistFile = Path.Combine(codeGenerator.Settings.GetManagedPluginSettingsDir(), "ModulesWhitelist.txt"); string blacklistFile = Path.Combine(codeGenerator.Settings.GetManagedPluginSettingsDir(), "ModulesBlacklist.txt"); if (File.Exists(whitelistFile)) { foreach (string line in File.ReadAllLines(whitelistFile)) { if (!string.IsNullOrEmpty(line)) { codeGenerator.ModulesNamesWhitelist.Add(line); } } } if (File.Exists(blacklistFile)) { foreach (string line in File.ReadAllLines(blacklistFile)) { if (!string.IsNullOrEmpty(line)) { codeGenerator.ModulesNamesBlacklist.Add(line); } } } codeGenerator.GenerateCodeForEngineModules(); break; case "all_modules": codeGenerator = new CodeGenerator(); codeGenerator.GenerateCodeForAllModules(); break; case "engine_modules": codeGenerator = new CodeGenerator(); codeGenerator.GenerateCodeForEngineModules(); break; case "module": if (args.Length > 1) { bool forceExport = false; if (args.Length > 2) { bool.TryParse(args[2], out forceExport); } codeGenerator = new CodeGenerator(); // Tests / using these for types for use in this lib //codeGenerator.Settings.CheckUObjectDestroyed = false; //codeGenerator.Settings.GenerateIsValidSafeguards = false; //codeGenerator.Settings.MergeEnumFiles = false; if (forceExport) { codeGenerator.Settings.ExportMode = CodeGeneratorSettings.CodeExportMode.All; codeGenerator.Settings.ExportAllFunctions = true; codeGenerator.Settings.ExportAllProperties = true; } codeGenerator.GenerateCodeForModule(args[1], true); } else { invalidArgs = true; } break; case "check_flags": { // This checks the flags for manually wrapped types Assembly[] assemblies = new Assembly[2]; assemblies[0] = Assembly.GetExecutingAssembly(); UClass engineClass = UClass.GetClass("/Script/Engine.Engine"); if (engineClass != null) { Type type = UClass.GetType(engineClass); if (type == null) { FMessage.Log(ELogVerbosity.Warning, "Failed to fine UEngine type"); } else { assemblies[1] = type.Assembly; } } else { FMessage.Log(ELogVerbosity.Warning, "Failed to fine UEngine class"); } foreach (Assembly assembly in assemblies) { if (assembly == null) { continue; } foreach (Type type in assembly.GetTypes()) { UMetaPathAttribute pathAttribute = type.GetCustomAttribute <UMetaPathAttribute>(false); if (pathAttribute != null && !string.IsNullOrEmpty(pathAttribute.Path)) { uint oldFlags = 0; if (type.IsSameOrSubclassOf(typeof(UObject))) { UClassAttribute classAttribute = type.GetCustomAttribute <UClassAttribute>(false); if (classAttribute != null) { oldFlags = (uint)classAttribute.Flags; } UClass unrealClass = UClass.GetClass(pathAttribute.Path); if (unrealClass != null) { if (oldFlags != (uint)unrealClass.ClassFlags) { FMessage.Log("old: 0x" + oldFlags.ToString("X8") + " new: 0x" + ((uint)unrealClass.ClassFlags).ToString("X8") + " path: " + unrealClass.GetPathName()); } } } else { UStructAttribute structAttribute = type.GetCustomAttribute <UStructAttribute>(false); if (structAttribute != null) { oldFlags = (uint)structAttribute.Flags; } UScriptStruct unrealStruct = UScriptStruct.GetStruct(pathAttribute.Path); if (unrealStruct != null) { if (oldFlags != (uint)unrealStruct.StructFlags) { FMessage.Log("old: 0x" + oldFlags.ToString("X8") + " new: 0x" + ((uint)unrealStruct.StructFlags).ToString("X8") + " path: " + unrealStruct.GetPathName()); } } } } } FMessage.Log("--------"); } } break; case "compile": CompileGeneratedCode(); break; default: invalidArgs = true; break; } } else { invalidArgs = true; } if (invalidArgs) { FMessage.Log(ELogVerbosity.Warning, "Invalid input. Provide one of the following: game, gameplugins, modules, module [ModuleName], compile"); } } catch (Exception e) { FMessage.Log(ELogVerbosity.Error, "Generate code failed. Error: \n" + e); } }