/// <summary> /// Does this ModPlatform include the equivalent BuildTarget? /// </summary> /// <param name="self">A ModPlatform instance.</param> /// <param name="buildTarget">The BuildTarget to check.</param> /// <returns>True if the ModPlatform has the BuildTarget.</returns> public static bool HasBuildTarget(this ModPlatform self, BuildTarget buildTarget) { switch (buildTarget) { case BuildTarget.StandaloneWindows: if ((self & ModPlatform.Windows) == ModPlatform.Windows) { return(true); } break; case BuildTarget.StandaloneLinuxUniversal: if ((self & ModPlatform.Linux) == ModPlatform.Linux) { return(true); } break; case BuildTarget.StandaloneOSX: if ((self & ModPlatform.OSX) == ModPlatform.OSX) { return(true); } break; case BuildTarget.Android: if ((self & ModPlatform.Android) == ModPlatform.Android) { return(true); } break; } return(false); }
private void BuildAssetBundles(ModPlatform platforms) { List <BuildTarget> buildTargets = platforms.GetBuildTargets(); foreach (BuildTarget buildTarget in buildTargets) { string platformSubdirectory = Path.Combine(tempModDirectory, buildTarget.GetModPlatform().ToString()); Directory.CreateDirectory(platformSubdirectory); BuildPipeline.BuildAssetBundles(platformSubdirectory, BuildAssetBundleOptions.None, buildTarget); } }
/// <summary> /// Does this ModPlatform include the equivalent RuntimePlatform? /// </summary> /// <param name="self">A ModPlatform instance.</param> /// <param name="runtimePlatform">A RuntimePlatform.</param> /// <returns>True if the ModPlatform includes the equivalent RuntimePlatform.</returns> public static bool HasRuntimePlatform(this ModPlatform self, RuntimePlatform runtimePlatform) { switch (runtimePlatform) { case RuntimePlatform.WindowsPlayer: if ((self & ModPlatform.Windows) == ModPlatform.Windows) { return(true); } break; case RuntimePlatform.WindowsEditor: if ((self & ModPlatform.Windows) == ModPlatform.Windows) { return(true); } break; case RuntimePlatform.LinuxPlayer: if ((self & ModPlatform.Linux) == ModPlatform.Linux) { return(true); } break; case RuntimePlatform.OSXPlayer: if ((self & ModPlatform.OSX) == ModPlatform.OSX) { return(true); } break; case RuntimePlatform.OSXEditor: if ((self & ModPlatform.OSX) == ModPlatform.OSX) { return(true); } break; case RuntimePlatform.Android: if ((self & ModPlatform.Android) == ModPlatform.Android) { return(true); } break; } return(false); }
/// <summary> /// Get a list of the equivalent RuntimePlatforms for this ModPlatform /// </summary> /// <param name="self">A ModPlatform instance.</param> /// <returns>A List of equivalent RuntimePlatforms.</returns> public static List <RuntimePlatform> GetRuntimePlatforms(this ModPlatform self) { List <RuntimePlatform> runtimePlatforms = new List <RuntimePlatform>(); var values = Enum.GetValues(typeof(RuntimePlatform)); foreach (RuntimePlatform r in values) { if (self.HasRuntimePlatform(r)) { runtimePlatforms.Add(r); } } return(runtimePlatforms); }
/// <summary> /// Get a list of BuildTargets that are equivalent to this ModPlatform. /// </summary> /// <param name="self">A ModPlatform Instance.</param> /// <returns>A list with equivalent BuildTargets</returns> public static List <BuildTarget> GetBuildTargets(this ModPlatform self) { var runtimePlatforms = new List <BuildTarget>(); var values = Enum.GetValues(typeof(BuildTarget)); foreach (BuildTarget r in values) { if (self.HasBuildTarget(r)) { runtimePlatforms.Add(r); } } return(runtimePlatforms); }
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(); } }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); ModPlatform supportedPlatforms = (ModPlatform)EditorGUILayout.EnumMaskField("Supported Platforms", (ModPlatform)_supportedPlatforms.intValue); ModContent supportedContent = (ModContent)EditorGUILayout.EnumMaskField("Supported Content", (ModContent)_supportedContent.intValue); LogLevel logLevel = (LogLevel)EditorGUILayout.EnumPopup("Log Level", (LogLevel)_logLevel.intValue); _supportedPlatforms.intValue = supportedPlatforms.FixEnum(); _supportedContent.intValue = supportedContent.FixEnum(); _logLevel.intValue = (int)logLevel; EditorGUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); }
/// <summary> /// Initialize a new ModInfo. /// </summary> /// <param name="name">The Mod's name.</param> /// <param name="author">The Mod's author.</param> /// <param name="description">The Mod's description.</param> /// <param name="platforms">The Mod's supported platforms.</param> /// <param name="content">The Mod's available content types.</param> /// <param name="version">The Mod's version</param> /// <param name="unityVersion"> The version of Unity that the Mod was exported with.</param> public ModInfo( string name, string author, string description, string version, string unityVersion, ModPlatform platforms, ModContent content) { _author = author; _description = description; _name = name; _platforms = platforms; _content = content; _version = version; _unityVersion = unityVersion; isEnabled = false; }