internal override void Execute(ExportSettings settings, ExportData data) { if ((data.content & ModContent.Code) != ModContent.Code) { return; } foreach (Asset script in data.scripts) { script.Delete(); } string prefix = data.prefix.Replace(" ", ""); if (!string.IsNullOrEmpty(settings.version)) { prefix += settings.version.Replace(" ", "") + "-"; } foreach (string scriptAssembly in scriptAssemblies) { string scriptAssemblyPath = Path.Combine(tempAssemblyDirectory, scriptAssembly); if (!File.Exists(scriptAssemblyPath)) { continue; } AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(scriptAssemblyPath); AssemblyNameDefinition assemblyName = assembly.Name; DefaultAssemblyResolver resolver = (DefaultAssemblyResolver)assembly.MainModule.AssemblyResolver; resolver.AddSearchDirectory(Path.GetDirectoryName(typeof(UnityEngine.Object).Assembly.Location)); resolver.AddSearchDirectory(assetsDirectory); assemblyName.Name = prefix + assemblyName.Name; foreach (var reference in assembly.MainModule.AssemblyReferences) { if (reference.Name.Contains("firstpass")) { reference.Name = prefix + reference.Name; } } scriptAssemblyPath = Path.Combine(modToolDirectory, assemblyName.Name + ".dll"); assembly.Write(scriptAssemblyPath); data.scriptAssemblies.Add(new Asset(scriptAssemblyPath)); } if (data.scriptAssemblies.Count > 0) { AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate | ImportAssetOptions.DontDownloadFromCacheServer); ForceAssemblyReload(); } }
private void StartExport() { data = new ExportData(); LogUtility.LogInfo("Exporting Mod: " + ExportSettings.name); ExportStarting?.Invoke(); currentStep = 0; Continue(); }
internal override void Execute(ExportData data) { data.loadedScene = SceneManager.GetActiveScene().path; if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) { throw new Exception("Cancelled by user"); } data.prefix = ExportSettings.name + "-"; EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); }
internal override void Execute(ExportData data) { tempModDirectory = Path.Combine("Temp", ExportSettings.name); modDirectory = Path.Combine(ExportSettings.outputDirectory, ExportSettings.name); if (Directory.Exists(tempModDirectory)) { Directory.Delete(tempModDirectory, true); } Directory.CreateDirectory(tempModDirectory); foreach (Asset assembly in data.assemblies) { assembly.Copy(tempModDirectory); } foreach (Asset assembly in data.scriptAssemblies) { assembly.Copy(tempModDirectory); } ModPlatform platforms = ExportSettings.platforms; BuildAssetBundles(platforms); ModInfo modInfo = new ModInfo( ExportSettings.name, ExportSettings.scene.ScenePath, ExportSettings.author, ExportSettings.description, ExportSettings.version, Application.unityVersion, platforms, data.content); ModInfo.Save(Path.Combine(tempModDirectory, ExportSettings.name + ".info"), modInfo); CopyToOutput(); if (data.scriptAssemblies.Count > 0) { ForceAssemblyReload(); } }
/// <summary> /// Start exporting a Mod. /// </summary> /// <param name="settings">The settings to use for exporting the Mod.</param> public void ExportMod(ExportSettings settings) { if (isExporting) { LogUtility.LogError("Already exporting"); return; } this.settings = settings; data = new ExportData(); LogUtility.LogInfo("Exporting Mod: " + settings.name); ExportStarting?.Invoke(); currentStep = 0; Continue(); }
internal override void Execute(ExportData data) { AssetDatabase.SaveAssets(); if (Directory.Exists(Asset.backupDirectory)) { Directory.Delete(Asset.backupDirectory, true); } Directory.CreateDirectory(Asset.backupDirectory); if (Directory.Exists(tempAssemblyDirectory)) { Directory.Delete(tempAssemblyDirectory, true); } Directory.CreateDirectory(tempAssemblyDirectory); foreach (Asset asset in data.assets) { asset.Backup(); } foreach (Asset scene in data.scenes) { scene.Backup(); } foreach (Asset script in data.scripts) { script.Backup(); } foreach (string path in Directory.GetFiles(assemblyDirectory)) { File.Copy(path, Path.Combine(tempAssemblyDirectory, Path.GetFileName(path))); } }
internal override void Execute(ExportData data) { data.assemblies = GetAssemblies(); data.assets = GetAssets("t:prefab t:scriptableobject"); data.scenes = GetAssets("t:scene"); data.scripts = GetAssets("t:monoscript"); ModContent content = ExportSettings.content; if (data.assets.Count == 0) { content &= ~ModContent.Assets; } if (data.scenes.Count == 0) { content &= ~ModContent.Scenes; } if (data.assemblies.Count == 0 && data.scripts.Count == 0) { content &= ~ModContent.Code; } data.content = content; }
internal override void Execute(ExportData data) { CheckSerializationMode(); VerifyProject(); VerifySettings(); }
internal abstract void Execute(ExportData data);
internal abstract void Execute(ExportSettings settings, ExportData data);