diff --git a/com.stansassets.scene-management/BuildConfigurator.meta b/com.stansassets.scene-management/BuildConfigurator.meta new file mode 100644 index 0000000..bb9fa5e --- /dev/null +++ b/com.stansassets.scene-management/BuildConfigurator.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 43fe8d95c4c654b5d9d0e689b6823d8d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.stansassets.scene-management/BuildConfigurator/BuildConfiguration.cs b/com.stansassets.scene-management/BuildConfigurator/BuildConfiguration.cs new file mode 100644 index 0000000..9a734b2 --- /dev/null +++ b/com.stansassets.scene-management/BuildConfigurator/BuildConfiguration.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using UnityEditor; + +namespace StansAssets.SceneManagement.Build +{ + [Serializable] + public class BuildConfiguration + { + public string Name = string.Empty; + public bool DefaultScenesFirst = false; + public List DefaultScenes = new List(); + public List Platforms = new List(); + + public bool IsEmpty => DefaultScenes.Count == 0 && Platforms.Count == 0; + + public BuildConfiguration Copy() + { + var copy = new BuildConfiguration(); + copy.Name = Name + " Copy"; + foreach (var scene in DefaultScenes) + { + copy.DefaultScenes.Add(scene); + } + + foreach (var platformsConfiguration in Platforms) + { + var p = new PlatformsConfiguration(); + foreach (var target in platformsConfiguration.BuildTargets) + { + p.BuildTargets.Add(target); + } + + foreach (var scene in platformsConfiguration.Scenes) + { + p.Scenes.Add(scene); + } + + copy.Platforms.Add(p); + } + + return copy; + } + } +} diff --git a/com.stansassets.scene-management/BuildConfigurator/BuildConfiguration.cs.meta b/com.stansassets.scene-management/BuildConfigurator/BuildConfiguration.cs.meta new file mode 100644 index 0000000..5f1fa7c --- /dev/null +++ b/com.stansassets.scene-management/BuildConfigurator/BuildConfiguration.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 521c51844235443988af3d0b4539ea61 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.stansassets.scene-management/BuildConfigurator/BuildConfigurationMenu.cs b/com.stansassets.scene-management/BuildConfigurator/BuildConfigurationMenu.cs new file mode 100644 index 0000000..8fd6686 --- /dev/null +++ b/com.stansassets.scene-management/BuildConfigurator/BuildConfigurationMenu.cs @@ -0,0 +1,12 @@ +using UnityEditor; + +namespace StansAssets.SceneManagement.Build +{ + public static class BuildConfigurationMenu + { + [MenuItem(SceneManagementPackage.RootMenu + "Build Settings", false, 1)] + public static void OpenBuildSettings() { + BuildConfigurationWindow.ShowTowardsInspector("Build Conf"); + } + } +} diff --git a/com.stansassets.scene-management/BuildConfigurator/BuildConfigurationMenu.cs.meta b/com.stansassets.scene-management/BuildConfigurator/BuildConfigurationMenu.cs.meta new file mode 100644 index 0000000..cdcdffc --- /dev/null +++ b/com.stansassets.scene-management/BuildConfigurator/BuildConfigurationMenu.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 46c4bee0355a42b1845af6b052f27a79 +timeCreated: 1598391452 \ No newline at end of file diff --git a/com.stansassets.scene-management/BuildConfigurator/BuildConfigurationSettings.cs b/com.stansassets.scene-management/BuildConfigurator/BuildConfigurationSettings.cs new file mode 100644 index 0000000..1421942 --- /dev/null +++ b/com.stansassets.scene-management/BuildConfigurator/BuildConfigurationSettings.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using StansAssets.Plugins; + +namespace StansAssets.SceneManagement.Build { + + public class BuildConfigurationSettings : PackageScriptableSettingsSingleton + { + protected override bool IsEditorOnly => true; + public override string PackageName => SceneManagementPackage.PackageName; + + + public int ActiveConfigurationIndex = 0; + public List BuildConfigurations = new List(); + + public BuildConfiguration Configuration => ActiveConfigurationIndex >= BuildConfigurations.Count + ? new BuildConfiguration() + : BuildConfigurations[ActiveConfigurationIndex]; + } +} \ No newline at end of file diff --git a/com.stansassets.scene-management/BuildConfigurator/BuildConfigurationSettings.cs.meta b/com.stansassets.scene-management/BuildConfigurator/BuildConfigurationSettings.cs.meta new file mode 100644 index 0000000..5e194e9 --- /dev/null +++ b/com.stansassets.scene-management/BuildConfigurator/BuildConfigurationSettings.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a132ec5216e554525ab899f3ded4c530 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.stansassets.scene-management/BuildConfigurator/BuildConfigurationWindow.cs b/com.stansassets.scene-management/BuildConfigurator/BuildConfigurationWindow.cs new file mode 100644 index 0000000..900acc2 --- /dev/null +++ b/com.stansassets.scene-management/BuildConfigurator/BuildConfigurationWindow.cs @@ -0,0 +1,285 @@ +using UnityEngine; +using UnityEditor; +using Rotorz.ReorderableList; +using StansAssets.Plugins.Editor; + +namespace StansAssets.SceneManagement.Build +{ + public class BuildConfigurationWindow : IMGUISettingsWindow + { + const string k_DefaultScenesDescription = "If you are leaving the default scnese empty, " + + "projects settings defined scene will be added to the build. " + + "When Defult Scenes have atleaest one scene defined, " + + "project scenes are ignored and only scene defined in this configuration will be used."; + + [SerializeField] + IMGUIHyperLabel m_AddButton; + + protected override void OnAwake() + { + SetHeaderTitle("Cross-Platform build configuration"); + SetHeaderDescription("Make configuration for every platform per different build types."); + + SetHeaderVersion("preview"); + SetDocumentationUrl("https://github.com/StansAssets/com.stansassets.scene-management"); + + if (BuildConfigurationSettings.Instance.BuildConfigurations.Count == 0) + { + var conf = new BuildConfiguration { Name = "Default" }; + BuildConfigurationSettings.Instance.BuildConfigurations.Add(conf); + } + + m_MenuToolbar = new IMGUIHyperToolbar(); + + foreach (var conf in BuildConfigurationSettings.Instance.BuildConfigurations) + { + AddBuildConfigurationTab(conf.Name); + } + + UpdateActiveConfUI(); + + m_AddButton = new IMGUIHyperLabel(new GUIContent("+"), EditorStyles.miniLabel); + m_AddButton.SetMouseOverColor(SettingsWindowStyles.SelectedElementColor); + } + + void UpdateActiveConfUI() + { + foreach (var btn in m_MenuToolbar.Buttons) + { + var index = m_MenuToolbar.Buttons.IndexOf(btn); + var contentText = BuildConfigurationSettings.Instance.BuildConfigurations[index].Name; + + if (index == BuildConfigurationSettings.Instance.ActiveConfigurationIndex) + { + contentText += " (A)"; + } + + btn.Content.text = contentText; + } + } + + void AddBuildConfigurationTab(string itemName) + { + var button = new IMGUIHyperLabel(new GUIContent(itemName), EditorStyles.boldLabel); + button.SetMouseOverColor(SettingsWindowStyles.SelectedElementColor); + m_MenuToolbar.AddButtons(button); + } + + protected override void BeforeGUI() + { + EditorGUI.BeginChangeCheck(); + } + + protected override void AfterGUI() + { + if (EditorGUI.EndChangeCheck()) + { + UpdateActiveConfUI(); + BuildConfigurationSettings.Save(); + } + } + + int m_SelectionIndex; + + protected override void OnLayoutGUI() + { + DrawToolbar(); + DrawHeader(); + + m_SelectionIndex = DrawTabs(); + + DrawScrollView(() => + { + DrawConfiguration(m_SelectionIndex); + }); + } + + void DrawConfiguration(int index) + { + var conf = BuildConfigurationSettings.Instance.BuildConfigurations[index]; + using (new IMGUIBlockWithIndent(new GUIContent("Settings"))) + { + conf.Name = IMGUILayout.TextField("Configuration Name:", conf.Name); + conf.DefaultScenesFirst = IMGUILayout.ToggleFiled("Default Scenes First", conf.DefaultScenesFirst, IMGUIToggleStyle.ToggleType.YesNo); + + GUILayout.Space(EditorGUIUtility.singleLineHeight); + using (new IMGUIBeginHorizontal()) + { + GUILayout.FlexibleSpace(); + + if (BuildConfigurationSettings.Instance.ActiveConfigurationIndex == index) + { + GUI.enabled = false; + } + + bool active = GUILayout.Button("Set As Active", GUILayout.Width(100)); + if (active) + { + BuildConfigurationSettings.Instance.ActiveConfigurationIndex = index; + UpdateActiveConfUI(); + } + + GUI.enabled = true; + + bool remove = GUILayout.Button("Remove", GUILayout.Width(100)); + if (remove) + { + BuildConfigurationSettings.Instance.BuildConfigurations.Remove(conf); + OnAwake(); + GUIUtility.ExitGUI(); + return; + } + } + } + + if (conf.DefaultScenesFirst) + { + DrawDefaultScenes(conf); + DrawPlatforms(conf); + } + else + { + DrawPlatforms(conf); + DrawDefaultScenes(conf); + } + } + + void DrawDefaultScenes(BuildConfiguration conf) + { + using (new IMGUIBlockWithIndent(new GUIContent("Default Scenes"))) + { + EditorGUILayout.HelpBox(k_DefaultScenesDescription, MessageType.Info); + using (new IMGUIBeginHorizontal()) + { + GUILayout.Space(20); + using (new IMGUIBeginVertical()) + { + ReorderableListGUI.ListField(conf.DefaultScenes, ContentTypeListItem, DrawEmptyScene); + } + } + } + } + + void DrawPlatforms(BuildConfiguration conf) + { + using (new IMGUIBlockWithIndent(new GUIContent("Platforms"))) + { + using (new IMGUIBeginHorizontal()) + { + GUILayout.Space(20); + using (new IMGUIBeginVertical()) + { + foreach (var platform in conf.Platforms) + { + EditorGUILayout.BeginHorizontal(GUI.skin.box); + { + EditorGUILayout.BeginVertical(GUILayout.Width(10)); + { + using (new IMGUIBeginHorizontal()) + { + GUILayout.Space(2); + bool delete = GUILayout.Button("-", EditorStyles.miniButton, GUILayout.Width(18)); + if (delete) + { + conf.Platforms.Remove(platform); + GUIUtility.ExitGUI(); + break; + } + + GUILayout.Space(-5); + } + } + EditorGUILayout.EndVertical(); + + EditorGUILayout.BeginVertical(GUILayout.Width(150)); + { + ReorderableListGUI.Title("Build Targets"); + ReorderableListGUI.ListField(platform.BuildTargets, BuildTargetListItem, DrawEmptyPlatform); + } + EditorGUILayout.EndVertical(); + + EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true)); + { + ReorderableListGUI.Title("Scenes"); + ReorderableListGUI.ListField(platform.Scenes, ContentTypeListItem, DrawEmptyScene); + } + EditorGUILayout.EndVertical(); + } + EditorGUILayout.EndHorizontal(); + } + } + } + + using (new IMGUIBeginHorizontal()) + { + GUILayout.FlexibleSpace(); + if (GUILayout.Button("+", GUILayout.Width(25))) + { + PlatformsConfiguration s = new PlatformsConfiguration(); + conf.Platforms.Add(s); + } + } + } + } + + BuildTarget BuildTargetListItem(Rect pos, BuildTarget itemValue) + { + int indentLevel = EditorGUI.indentLevel; + EditorGUI.indentLevel = 0; + BuildTarget target = (BuildTarget)EditorGUI.EnumPopup(pos, itemValue); + EditorGUI.indentLevel = indentLevel; + return target; + } + + SceneAsset ContentTypeListItem(Rect pos, SceneAsset itemValue) + { + int indentLevel = EditorGUI.indentLevel; + EditorGUI.indentLevel = 0; + var assets = EditorGUI.ObjectField(pos, itemValue, typeof(SceneAsset), false) as SceneAsset; + EditorGUI.indentLevel = indentLevel; + return assets; + } + + void DrawEmptyScene() + { + GUILayout.Label("Add a scenes", EditorStyles.miniLabel); + } + + void DrawEmptyPlatform() + { + GUILayout.Label("Add a build target", EditorStyles.miniLabel); + } + + protected int DrawTabs() + { + GUILayout.Space(2); + + int index; + using (new IMGUIBeginHorizontal()) + { + using (new IMGUIBeginVertical()) + { + index = m_MenuToolbar.Draw(); + } + + var add = m_AddButton.Draw(GUILayout.Width(20)); + if (add) + { + var conf = BuildConfigurationSettings.Instance.BuildConfigurations[m_SelectionIndex]; + var copy = conf.Copy(); + BuildConfigurationSettings.Instance.BuildConfigurations.Add(copy); + AddBuildConfigurationTab(copy.Name); + GUIUtility.ExitGUI(); + } + } + + GUILayout.Space(4); + + EditorGUILayout.BeginVertical(SettingsWindowStyles.SeparationStyle); + GUILayout.Space(5); + EditorGUILayout.EndVertical(); + + return index; + } + } +} diff --git a/com.stansassets.scene-management/BuildConfigurator/BuildConfigurationWindow.cs.meta b/com.stansassets.scene-management/BuildConfigurator/BuildConfigurationWindow.cs.meta new file mode 100644 index 0000000..f831619 --- /dev/null +++ b/com.stansassets.scene-management/BuildConfigurator/BuildConfigurationWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 05dfd5fcfe5764f9c81adbb3c5cde5c5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.stansassets.scene-management/BuildConfigurator/BuildScenesPreprocessor.cs b/com.stansassets.scene-management/BuildConfigurator/BuildScenesPreprocessor.cs new file mode 100644 index 0000000..4da9170 --- /dev/null +++ b/com.stansassets.scene-management/BuildConfigurator/BuildScenesPreprocessor.cs @@ -0,0 +1,117 @@ +using UnityEngine; +using UnityEditor; +using System; +using System.Collections.Generic; + +namespace StansAssets.SceneManagement.Build +{ + [InitializeOnLoad] + public class BuildScenesPreprocessor + { + static readonly List> s_BuildHandlers = new List>(); + + public static void RegisterBuildPlayerHandler(Action handler) + { + s_BuildHandlers.Add(handler); + } + + static BuildScenesPreprocessor() + { + BuildPlayerWindow.RegisterBuildPlayerHandler((options) => + { + SetupBuildOptions(ref options); + EditorApplication.delayCall += () => + { + Debug.Log("Scenes list " + string.Join(", \n", options.scenes)); + BuildPlayerWindow.DefaultBuildMethods.BuildPlayer(options); + }; + }); + } + + public static void SetupBuildOptions(ref BuildPlayerOptions options) + { + foreach (var handler in s_BuildHandlers) + { + handler.Invoke(options); + } + + options.scenes = FilterScenesByPath(EditorUserBuildSettings.activeBuildTarget, options.scenes); + } + + static string[] FilterScenesByPath(BuildTarget target, string[] buildScenes) + { + var configuration = BuildConfigurationSettings.Instance.Configuration; + if (configuration.IsEmpty) + { + return buildScenes; + } + + List scenes = new List(); + + if (configuration.DefaultScenes.Count == 0) + { + scenes.AddRange(buildScenes); + ProcessPlatforms(ref scenes, target, configuration.Platforms); + } + else + { + if (configuration.DefaultScenesFirst) + { + ProcessPlatforms(ref scenes, target, configuration.Platforms); + InsertScenes(ref scenes, configuration.DefaultScenes); + } + else + { + InsertScenes(ref scenes, configuration.DefaultScenes); + ProcessPlatforms(ref scenes, target, configuration.Platforms); + } + } + + return scenes.ToArray(); + } + + static void ProcessPlatforms(ref List scenes, BuildTarget target, List platforms) + { + foreach (var platformsConfiguration in platforms) + { + if (platformsConfiguration.BuildTargets.Contains(target)) + { + InsertScenes(ref scenes, platformsConfiguration.Scenes); + } + else + { + RemoveScenes(ref scenes, platformsConfiguration.Scenes); + } + } + } + + static void InsertScenes(ref List scenes, List sceneAssets) + { + for (var index = 0; index < sceneAssets.Count; index++) + { + var sceneAssetPath = AssetDatabase.GetAssetPath(sceneAssets[index]); + if (string.IsNullOrEmpty(sceneAssetPath)) + continue; + + if (scenes.Contains(sceneAssetPath)) + { + scenes.Remove(sceneAssetPath); + } + + scenes.Insert(index, sceneAssetPath); + } + } + + static void RemoveScenes(ref List scenes, List sceneAssets) + { + foreach (var sceneAsset in sceneAssets) + { + var sceneAssetPath = AssetDatabase.GetAssetPath(sceneAsset); + if (scenes.Contains(sceneAssetPath)) + { + scenes.Remove(sceneAssetPath); + } + } + } + } +} diff --git a/com.stansassets.scene-management/BuildConfigurator/BuildScenesPreprocessor.cs.meta b/com.stansassets.scene-management/BuildConfigurator/BuildScenesPreprocessor.cs.meta new file mode 100644 index 0000000..f633329 --- /dev/null +++ b/com.stansassets.scene-management/BuildConfigurator/BuildScenesPreprocessor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e33f9d48d3ac14fa2887e90c39e3ed95 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.stansassets.scene-management/BuildConfigurator/PlatformsConfiguration.cs b/com.stansassets.scene-management/BuildConfigurator/PlatformsConfiguration.cs new file mode 100644 index 0000000..02db146 --- /dev/null +++ b/com.stansassets.scene-management/BuildConfigurator/PlatformsConfiguration.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace StansAssets.SceneManagement.Build +{ + [Serializable] + public class PlatformsConfiguration + { + public List BuildTargets = new List(); + public List Scenes = new List(); + } +} \ No newline at end of file diff --git a/com.stansassets.scene-management/BuildConfigurator/PlatformsConfiguration.cs.meta b/com.stansassets.scene-management/BuildConfigurator/PlatformsConfiguration.cs.meta new file mode 100644 index 0000000..debc796 --- /dev/null +++ b/com.stansassets.scene-management/BuildConfigurator/PlatformsConfiguration.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 294756d6946724bce849d4c155e66979 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.stansassets.scene-management/BuildConfigurator/StansAssets.SceneManagement.Build.asmdef b/com.stansassets.scene-management/BuildConfigurator/StansAssets.SceneManagement.Build.asmdef new file mode 100644 index 0000000..569ace1 --- /dev/null +++ b/com.stansassets.scene-management/BuildConfigurator/StansAssets.SceneManagement.Build.asmdef @@ -0,0 +1,20 @@ +{ + "name": "StansAssets.SceneManagement.Build", + "references": [ + "StansAssets.Foundation.Editor", + "StansAssets.Foundation", + "StansAssets.Plugins", + "StansAssets.Plugins.Editor", + "StansAssets.SceneManagement.Editor" + ], + "optionalUnityReferences": [], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [] +} \ No newline at end of file diff --git a/com.stansassets.scene-management/BuildConfigurator/StansAssets.SceneManagement.Build.asmdef.meta b/com.stansassets.scene-management/BuildConfigurator/StansAssets.SceneManagement.Build.asmdef.meta new file mode 100644 index 0000000..5eb6ba6 --- /dev/null +++ b/com.stansassets.scene-management/BuildConfigurator/StansAssets.SceneManagement.Build.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 46e475aa66f8a486a8a1610f3cab7276 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.stansassets.scene-management/Editor/AssemblyInfo.cs b/com.stansassets.scene-management/Editor/AssemblyInfo.cs new file mode 100644 index 0000000..38da05f --- /dev/null +++ b/com.stansassets.scene-management/Editor/AssemblyInfo.cs @@ -0,0 +1,2 @@ +using System.Runtime.CompilerServices; +[assembly: InternalsVisibleTo("StansAssets.SceneManagement.Build")] diff --git a/com.stansassets.scene-management/Editor/AssemblyInfo.cs.meta b/com.stansassets.scene-management/Editor/AssemblyInfo.cs.meta new file mode 100644 index 0000000..25b95fc --- /dev/null +++ b/com.stansassets.scene-management/Editor/AssemblyInfo.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0f0f74826bc84095bb35ec9e82eb3981 +timeCreated: 1598393999 \ No newline at end of file diff --git a/com.stansassets.scene-management/Editor/Configs/SceneManagementPackage.cs b/com.stansassets.scene-management/Editor/Configs/SceneManagementPackage.cs index 61956b6..da7fe28 100644 --- a/com.stansassets.scene-management/Editor/Configs/SceneManagementPackage.cs +++ b/com.stansassets.scene-management/Editor/Configs/SceneManagementPackage.cs @@ -1,4 +1,5 @@ using StansAssets.Foundation.Editor; +using StansAssets.Plugins.Editor; using UnityEditor.PackageManager; namespace StansAssets.SceneManagement @@ -7,9 +8,13 @@ static class SceneManagementPackage { public const string PackageName = "com.stansassets.scene-management"; public const string DisplayName = "Scene Management"; + public const string RootMenu = PackagesConfigEditor.RootMenu + "/" + DisplayName + "/"; public static readonly string RootPath = PackageManagerUtility.GetPackageRootPath(PackageName); + +#if UNITY_2019_4_OR_NEWER public static readonly PackageInfo Info = PackageManagerUtility.GetPackageInfo(PackageName); +#endif internal static readonly string WindowTabsPath = $"{RootPath}/Editor/Window/Tabs"; } diff --git a/com.stansassets.scene-management/Editor/Settings/SceneManagementEditorMenu.cs b/com.stansassets.scene-management/Editor/Settings/SceneManagementEditorMenu.cs index 4433f92..631ddf5 100644 --- a/com.stansassets.scene-management/Editor/Settings/SceneManagementEditorMenu.cs +++ b/com.stansassets.scene-management/Editor/Settings/SceneManagementEditorMenu.cs @@ -1,25 +1,25 @@ +#if UNITY_2019_4_OR_NEWER using StansAssets.Plugins.Editor; using UnityEditor; -using UnityEditor.SceneManagement; -using UnityEngine; namespace StansAssets.SceneManagement { static class SceneManagementEditorMenu { - const string k_RootMenu = PackagesConfigEditor.RootMenu + "/" + SceneManagementPackage.DisplayName + "/"; - [MenuItem(k_RootMenu + "Settings", false, 0)] + [MenuItem(SceneManagementPackage.RootMenu + "Settings", false, 0)] public static void OpenSettings() { var windowTitle = SceneManagementSettingsWindow.WindowTitle; SceneManagementSettingsWindow.ShowTowardsInspector(windowTitle.text, windowTitle.image); } - [MenuItem(k_RootMenu + "Start Landing &p", false, 1000)] + + [MenuItem(SceneManagementPackage.RootMenu + "Start Landing &p", false, 1000)] public static void PlayMode() { StartLandingAction.Execute(); } } } +#endif diff --git a/com.stansassets.scene-management/Editor/Settings/SceneManagementSettings.cs b/com.stansassets.scene-management/Editor/Settings/SceneManagementSettings.cs index 3d46b42..8d6a403 100644 --- a/com.stansassets.scene-management/Editor/Settings/SceneManagementSettings.cs +++ b/com.stansassets.scene-management/Editor/Settings/SceneManagementSettings.cs @@ -8,10 +8,12 @@ public class SceneManagementSettings : PackageScriptableSettingsSingleton true; public override string PackageName => SceneManagementPackage.PackageName; + +#if UNITY_2019_4_OR_NEWER public SceneAsset LandingScene; - internal List OpenScenesBeforeLandingStart; internal int LastActiveSceneIndex; internal SceneViewInfo LastSceneView; +#endif } } diff --git a/com.stansassets.scene-management/Editor/Settings/StartLandingAction.cs b/com.stansassets.scene-management/Editor/Settings/StartLandingAction.cs index a7b3d80..cbb6361 100644 --- a/com.stansassets.scene-management/Editor/Settings/StartLandingAction.cs +++ b/com.stansassets.scene-management/Editor/Settings/StartLandingAction.cs @@ -1,3 +1,4 @@ +#if UNITY_2019_4_OR_NEWER using System.Collections.Generic; using UnityEditor; using UnityEngine; @@ -132,3 +133,4 @@ static void OpenScene(SceneStateInfo sceneStateInfo) } } } +#endif \ No newline at end of file diff --git a/com.stansassets.scene-management/Editor/StansAssets.SceneManagement.Editor.asmdef b/com.stansassets.scene-management/Editor/StansAssets.SceneManagement.Editor.asmdef index 6c408bb..4d8e762 100644 --- a/com.stansassets.scene-management/Editor/StansAssets.SceneManagement.Editor.asmdef +++ b/com.stansassets.scene-management/Editor/StansAssets.SceneManagement.Editor.asmdef @@ -6,6 +6,7 @@ "StansAssets.Plugins", "StansAssets.Plugins.Editor" ], + "optionalUnityReferences": [], "includePlatforms": [ "Editor" ], @@ -14,7 +15,5 @@ "overrideReferences": false, "precompiledReferences": [], "autoReferenced": false, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false + "defineConstraints": [] } \ No newline at end of file diff --git a/com.stansassets.scene-management/Editor/Window/SceneManagementSettingsWindow.cs b/com.stansassets.scene-management/Editor/Window/SceneManagementSettingsWindow.cs index db32bc0..8b92a20 100644 --- a/com.stansassets.scene-management/Editor/Window/SceneManagementSettingsWindow.cs +++ b/com.stansassets.scene-management/Editor/Window/SceneManagementSettingsWindow.cs @@ -1,4 +1,5 @@ -using StansAssets.Foundation.Editor; +#if UNITY_2019_4_OR_NEWER +using StansAssets.Foundation.Editor; using StansAssets.Plugins.Editor; using UnityEngine; using UnityEngine.UIElements; @@ -20,3 +21,4 @@ protected override void OnWindowEnable(VisualElement root) public static GUIContent WindowTitle => new GUIContent(SceneManagementPackage.DisplayName); } } +#endif \ No newline at end of file diff --git a/com.stansassets.scene-management/Editor/Window/Tabs/SettingsTab.cs b/com.stansassets.scene-management/Editor/Window/Tabs/SettingsTab.cs index 8884d3b..99072b8 100644 --- a/com.stansassets.scene-management/Editor/Window/Tabs/SettingsTab.cs +++ b/com.stansassets.scene-management/Editor/Window/Tabs/SettingsTab.cs @@ -1,4 +1,5 @@ -using StansAssets.Plugins.Editor; +#if UNITY_2019_4_OR_NEWER +using StansAssets.Plugins.Editor; using UnityEditor; using UnityEditor.UIElements; using UnityEngine; @@ -9,7 +10,7 @@ namespace StansAssets.SceneManagement public class SettingsTab : BaseTab { public SettingsTab() - : base($"{SceneManagementPackage.WindowTabsPath}/SettingsTab.uxml") + : base($"{SceneManagementPackage.WindowTabsPath}/SettingsTab") { var landingSceneField = Root.Q("landing-scene"); landingSceneField.objectType = typeof(SceneAsset); @@ -23,3 +24,4 @@ public SettingsTab() } } } +#endif \ No newline at end of file diff --git a/com.stansassets.scene-management/Editor/Window/Tabs/SettingsTab.uss.meta b/com.stansassets.scene-management/Editor/Window/Tabs/SettingsTab.uss.meta index a75e540..135f3eb 100644 --- a/com.stansassets.scene-management/Editor/Window/Tabs/SettingsTab.uss.meta +++ b/com.stansassets.scene-management/Editor/Window/Tabs/SettingsTab.uss.meta @@ -1,11 +1,10 @@ fileFormatVersion: 2 guid: 612876047d61d4ee0b61cbc10f676d29 ScriptedImporter: - internalIDToNameTable: [] + fileIDToRecycleName: + 11400000: stylesheet externalObjects: {} - serializedVersion: 2 userData: assetBundleName: assetBundleVariant: script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0} - disableValidation: 0 diff --git a/com.stansassets.scene-management/Editor/Window/Tabs/SettingsTab.uxml b/com.stansassets.scene-management/Editor/Window/Tabs/SettingsTab.uxml index 516c894..d7bdcd6 100644 --- a/com.stansassets.scene-management/Editor/Window/Tabs/SettingsTab.uxml +++ b/com.stansassets.scene-management/Editor/Window/Tabs/SettingsTab.uxml @@ -1,7 +1,5 @@ -