diff --git a/Client/Assets/Editor/Build/ReleaseTools.cs b/Client/Assets/Editor/Build/ReleaseTools.cs index 0ee3a54..a793fe9 100644 --- a/Client/Assets/Editor/Build/ReleaseTools.cs +++ b/Client/Assets/Editor/Build/ReleaseTools.cs @@ -159,7 +159,7 @@ namespace BuildCli } } - [MenuItem("Build/Build Test")] + [MenuItem("开发工具/Build/Build Test")] public static void BuildAAA() { string outPath = System.IO.Path.Combine(Application.dataPath, "../../bundles/"); @@ -179,7 +179,7 @@ namespace BuildCli BuildTest(outPath, version); BuildUpdateData(version); } - + static void BuildUpdateData(string version) { string outPath = System.IO.Path.Combine(Application.dataPath, "../../bundles/"); @@ -232,6 +232,7 @@ namespace BuildCli { Directory.CreateDirectory(targetPath); } + DeleteFilesInDirectory(targetPath); CopyFiles(bundlePath, targetPath); @@ -370,4 +371,4 @@ namespace BuildCli } } } -} \ No newline at end of file +} diff --git a/Client/Assets/Editor/PlayModePlus.meta b/Client/Assets/Editor/PlayModePlus.meta new file mode 100644 index 0000000..9d1429d --- /dev/null +++ b/Client/Assets/Editor/PlayModePlus.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b2046c8d71ec8bb4289cae8890231bc7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Editor/PlayModePlus/BuildManager.cs b/Client/Assets/Editor/PlayModePlus/BuildManager.cs new file mode 100644 index 0000000..da76416 --- /dev/null +++ b/Client/Assets/Editor/PlayModePlus/BuildManager.cs @@ -0,0 +1,47 @@ +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEditor.Presets; +using UnityEngine; + +namespace BuildCli +{ + public class BuildManager + { + public Preset SelectedBuildPreset; + public Preset[] PlayerSettingsPresetsInProject; + + public void OpenBuildWindow() + { +#if UNITY_6000_0_OR_NEWER + EditorApplication.ExecuteMenuItem("File/Build Profiles"); +#else + var buildPlayerWindow = EditorWindow.GetWindow("Build Settings"); + buildPlayerWindow.Show(); +#endif + } + + public static void ApplyPreset(Preset preset) + { + var projectSettings = Resources.FindObjectsOfTypeAll(); + + foreach (var settings in projectSettings) + { + preset.ApplyTo(settings); + } + } + + public List GenerateBuildSettingsList() + { + PlayerSettingsPresetsInProject = AssetDatabase.FindAssets("t:Preset") + .Select(AssetDatabase.GUIDToAssetPath) + .Where(path => path.Contains("PlayerSettings")) + .Select(AssetDatabase.LoadAssetAtPath) + .ToArray(); + + var buildPresetsList = new List(PlayerSettingsPresetsInProject.Select(preset => preset.name)); + + return buildPresetsList; + } + } +} \ No newline at end of file diff --git a/Client/Packages/com.alicizax.unity/Runtime/Utility/Log.cs.meta b/Client/Assets/Editor/PlayModePlus/BuildManager.cs.meta similarity index 83% rename from Client/Packages/com.alicizax.unity/Runtime/Utility/Log.cs.meta rename to Client/Assets/Editor/PlayModePlus/BuildManager.cs.meta index 136d75d..fe64b6d 100644 --- a/Client/Packages/com.alicizax.unity/Runtime/Utility/Log.cs.meta +++ b/Client/Assets/Editor/PlayModePlus/BuildManager.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: dea5e7b095c6d3b4ea334c381fcd16fb +guid: 3ad015755f8508d48ba8bca98199bf77 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Client/Assets/Editor/PlayModePlus/CustomUnityToolbar.cs b/Client/Assets/Editor/PlayModePlus/CustomUnityToolbar.cs new file mode 100644 index 0000000..657e0f8 --- /dev/null +++ b/Client/Assets/Editor/PlayModePlus/CustomUnityToolbar.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using UnityEditor; + +namespace BuildCli +{ + [InitializeOnLoad] + public static class CustomUnityToolbar + { + private static readonly List LeftToolbarGUI = new(); + private static readonly List RightToolbarGUI = new(); + + static CustomUnityToolbar() + { + CustomUnityToolbarCallback.OnToolbarGUILeft = () => { DrawToolbar(LeftToolbarGUI); }; + CustomUnityToolbarCallback.OnToolbarGUIRight = () => { DrawToolbar(RightToolbarGUI); }; + } + + private static void DrawToolbar(List toolbarActions) + { + EditorGUILayout.BeginHorizontal(); + foreach (var action in toolbarActions) action(); + + EditorGUILayout.EndHorizontal(); + } + } +} diff --git a/Client/Assets/Editor/PlayModePlus/CustomUnityToolbar.cs.meta b/Client/Assets/Editor/PlayModePlus/CustomUnityToolbar.cs.meta new file mode 100644 index 0000000..1a23d8b --- /dev/null +++ b/Client/Assets/Editor/PlayModePlus/CustomUnityToolbar.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c6b91b4b79d447e419bcf0a0509b2a92 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Editor/PlayModePlus/CustomUnityToolbarCallback.cs b/Client/Assets/Editor/PlayModePlus/CustomUnityToolbarCallback.cs new file mode 100644 index 0000000..c107df9 --- /dev/null +++ b/Client/Assets/Editor/PlayModePlus/CustomUnityToolbarCallback.cs @@ -0,0 +1,58 @@ +using System; +using System.Reflection; +using UnityEditor; +using UnityEngine; +using UnityEngine.UIElements; + +namespace BuildCli +{ + public static class CustomUnityToolbarCallback + { + private static readonly Type MToolbarType = typeof(UnityEditor.Editor).Assembly.GetType("UnityEditor.Toolbar"); + + private static ScriptableObject _mCurrentToolbar; + + private static Action _onToolbarGUI; + public static Action OnToolbarGUILeft; + public static Action OnToolbarGUIRight; + + static CustomUnityToolbarCallback() + { + EditorApplication.delayCall -= OnUpdate; + EditorApplication.delayCall += OnUpdate; + } + + private static void OnUpdate() + { + if (_mCurrentToolbar != null) return; + var toolbars = Resources.FindObjectsOfTypeAll(MToolbarType); + _mCurrentToolbar = toolbars.Length > 0 ? (ScriptableObject) toolbars[0] : null; + + if (_mCurrentToolbar == null) return; + var root = _mCurrentToolbar.GetType() + .GetField("m_Root", BindingFlags.NonPublic | BindingFlags.Instance); + var mRoot = root?.GetValue(_mCurrentToolbar) as VisualElement; + + if (mRoot == null) return; + var playButton = mRoot.Q("Play"); + var extendedPlayModeToolbar = new PlayModeToolbar(); + mRoot.Q("ToolbarZoneRightAlign").Add(extendedPlayModeToolbar); + + RegisterCallback("ToolbarZoneLeftAlign", OnToolbarGUILeft); + RegisterCallback("ToolbarZoneRightAlign", OnToolbarGUIRight); + } + + private static void RegisterCallback(string root, Action action) + { + var toolbarZone = + _mCurrentToolbar?.GetType().GetProperty(root)?.GetValue(_mCurrentToolbar) as VisualElement; + + if (toolbarZone == null) return; + var container = new IMGUIContainer(); + container.onGUIHandler = () => { action?.Invoke(); }; + container.style.flexGrow = 1; + container.style.flexDirection = FlexDirection.Row; + toolbarZone.Add(container); + } + } +} \ No newline at end of file diff --git a/Client/Assets/Editor/PlayModePlus/CustomUnityToolbarCallback.cs.meta b/Client/Assets/Editor/PlayModePlus/CustomUnityToolbarCallback.cs.meta new file mode 100644 index 0000000..58314f8 --- /dev/null +++ b/Client/Assets/Editor/PlayModePlus/CustomUnityToolbarCallback.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b47cc5ca0cc1d7a48906f362e261b472 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Editor/PlayModePlus/LICENSE.md b/Client/Assets/Editor/PlayModePlus/LICENSE.md new file mode 100644 index 0000000..33e6a71 --- /dev/null +++ b/Client/Assets/Editor/PlayModePlus/LICENSE.md @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2024 Disillusion +Copyright (c) 2023-2024 TippingGame tippinggame@163.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Client/Assets/Editor/PlayModePlus/LICENSE.md.meta b/Client/Assets/Editor/PlayModePlus/LICENSE.md.meta new file mode 100644 index 0000000..b34965c --- /dev/null +++ b/Client/Assets/Editor/PlayModePlus/LICENSE.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8da90e55807a3d24bac1ac41360d16bd +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Editor/PlayModePlus/PlayModeManager.cs b/Client/Assets/Editor/PlayModePlus/PlayModeManager.cs new file mode 100644 index 0000000..832acb6 --- /dev/null +++ b/Client/Assets/Editor/PlayModePlus/PlayModeManager.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEditor.SceneManagement; +using UnityEngine; +using YooAsset; + +namespace BuildCli +{ + public class PlayModeManager + { + private string[] _playmodeSettings; + + private Dictionary _resourceModeSettings = new Dictionary + { + { "编辑器模式", EPlayMode.EditorSimulateMode }, + { "单机模式", EPlayMode.OfflinePlayMode }, + { "热更模式", EPlayMode.HostPlayMode }, + }; + + private static string PrefsKey => Application.dataPath.GetHashCode() + "GamePlayMode"; + + public static void EditorStartScene() => EditorSceneManager.playModeStartScene = null; + + public void PlayScene() + { + if (!EditorApplication.isPlaying) + { + EditorApplication.isPlaying = true; + } + else + EditorApplication.isPlaying = false; + } + + + public List GenerateResourceModeList() + { + return _resourceModeSettings.Keys.ToList(); + } + + + public void SetPlayMode(string value) + { + if (_resourceModeSettings.TryGetValue(value, out EPlayMode playMode)) + { + EditorPrefs.SetInt(PrefsKey, (int)playMode); + } + } + + + public int GetSelectPlayMode() + { + var selectIndex = EditorPrefs.GetInt(PrefsKey, -1); + if (selectIndex == -1) + { + selectIndex = (int)EPlayMode.EditorSimulateMode; + EditorPrefs.SetInt(PrefsKey, selectIndex); + } + return selectIndex; + } + + public string GetSelectPlayModeValue() + { + var selectIndex = EditorPrefs.GetInt(PrefsKey, -1); + if (selectIndex == -1) + { + selectIndex = (int)EPlayMode.EditorSimulateMode; + EditorPrefs.SetInt(PrefsKey, selectIndex); + } + + EPlayMode mode = (EPlayMode)selectIndex; + return mode.ToString(); + } + + + public List GeneratePlayModeSettingsList() + { + _playmodeSettings = new[] + { + "Default (Reload Domain, Reload Scene)", "Disable Reload Domain", "Disable Reload Scene", "Disable All" + }; + + var playModeSettingsList = new List(_playmodeSettings); + + return playModeSettingsList; + } + } +} diff --git a/Client/Assets/Editor/PlayModePlus/PlayModeManager.cs.meta b/Client/Assets/Editor/PlayModePlus/PlayModeManager.cs.meta new file mode 100644 index 0000000..603160f --- /dev/null +++ b/Client/Assets/Editor/PlayModePlus/PlayModeManager.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b51aeed2989245259b93bddc8922b086 +timeCreated: 1676311145 \ No newline at end of file diff --git a/Client/Assets/Editor/PlayModePlus/PlayModePlus.uss b/Client/Assets/Editor/PlayModePlus/PlayModePlus.uss new file mode 100644 index 0000000..f67ef39 --- /dev/null +++ b/Client/Assets/Editor/PlayModePlus/PlayModePlus.uss @@ -0,0 +1,133 @@ +.plus-button { + background-color: rgb(56, 56, 56); + border-top-left-radius: 5px; + border-bottom-left-radius: 5px; + border-color: rgba(56, 56, 56, 0); + border-width: 11px; +} + +.plus-button:hover { + background-color: rgb(75, 75, 75); + -unity-background-image-tint-color: rgb(255, 255, 255); + -unity-background-scale-mode: scale-to-fit; +} + +.plus-button:active { + background-color: rgb(0, 0, 0); + -unity-background-image-tint-color: rgb(89, 158, 94); +} + +.unity-base-field { + width: 31px; + height: 100%; + background-image: none; + background-color: rgba(0, 0, 0, 0); + -unity-background-scale-mode: scale-to-fit; + justify-content: center; + margin-left: 0px; + margin-right: 1px; + margin-top: 0px; + margin-bottom: 0px; + border-top-width: 0px; +} + +.unity-base-field:hover .unity-base-popup-field__input { + background-color: rgb(75, 75, 75); + -unity-background-image-tint-color: rgb(255, 255, 255); +} + +.unity-base-field__input { + padding-bottom: 0px; + border-width: 0px; + border-top-width: 0px; + justify-content: center; + align-items: center; + height: 100%; + -unity-background-scale-mode: scale-to-fit; +} + +.unity-base-popup-field__input { + border-radius: 0px; + -unity-background-scale-mode: scale-to-fit; + border-top-width: 0px; + min-width: 31px; + background-color: rgb(56, 56, 56); + background-image: none; + justify-content: center; + align-items: center; + height: 100%; +} + +.scene-select-dropdown .unity-base-popup-field__input { + background-image: url('project://database/Packages/com.disillusion.play-mode-plus/Editor/Resources/com.disillusion.play-mode-plus/CustomDropdownArrow.png?fileID=2800000&guid=d56d19b3e6d0fc0419cda6972838d5ba&type=3#CustomDropdownArrow'); + -unity-background-scale-mode: scale-to-fit; + width: 14px; + height: 21px; + margin-left: 0px; + margin-right: 0px; + margin-top: 0px; + margin-bottom: 0px; + justify-content: center; + padding-left: 0px; + padding-right: 0px; + padding-top: 0px; + padding-bottom: 0px; + border-top-right-radius: 5px; + border-bottom-right-radius: 5px; + border-top-left-radius: 5px; + border-bottom-left-radius: 5px; + border-color: rgba(56, 56, 56, 0); + border-width: 11px; +} + +.play-mode-settings-dropdown .unity-base-popup-field__input { + background-image: url('project://database/Packages/com.disillusion.play-mode-plus/Editor/Resources/com.disillusion.play-mode-plus/CustomSceneCogButton.png?fileID=2800000&guid=b620a07f1fa7bf54b874f9661d2c6140&type=3#CustomSceneCogButton'); + -unity-background-scale-mode: scale-to-fit; + border-color: rgba(56, 56, 56, 0); + border-width: 11px; + border-radius: 5px; +} + +.build-settings-select-dropdown .unity-base-popup-field__input { + background-image: url('project://database/Packages/com.disillusion.play-mode-plus/Editor/Resources/com.disillusion.play-mode-plus/CustomDropdownArrow.png?fileID=2800000&guid=d56d19b3e6d0fc0419cda6972838d5ba&type=3#CustomDropdownArrow'); + -unity-background-scale-mode: scale-to-fit; + width: auto; + height: 21px; + justify-content: center; + border-top-right-radius: 5px; + border-bottom-right-radius: 5px; + border-color: rgba(56, 56, 56, 0); + border-width: 11px; +} + +.dropdown-override { + border-top-right-radius: 5px; + border-bottom-right-radius: 5px; + border-color: rgba(56, 56, 56, 0); + border-width: 8px; + width: 6px; + margin-left: 9px; + margin-right: 12px; + padding: 0px; +} + +.unity-base-popup-field__input:hover { + background-color: rgb(75, 75, 75); + -unity-background-image-tint-color: rgb(255, 255, 255); +} + +.unity-base-popup-field__arrow { + display: none; + border-top-right-radius: 5px; + border-bottom-right-radius: 5px; + border-color: rgba(56, 56, 56, 0); + border-width: 11px; +} + +.unity-base-popup-field__text { + display: none; + border-top-right-radius: 5px; + border-bottom-right-radius: 5px; + border-color: rgba(56, 56, 56, 0); + border-width: 11px; +} diff --git a/Client/Assets/Editor/PlayModePlus/PlayModePlus.uss.meta b/Client/Assets/Editor/PlayModePlus/PlayModePlus.uss.meta new file mode 100644 index 0000000..7945856 --- /dev/null +++ b/Client/Assets/Editor/PlayModePlus/PlayModePlus.uss.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 88ed63fd5c4857c43a3dbb9672116bb3 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0} + disableValidation: 0 diff --git a/Client/Assets/Editor/PlayModePlus/PlayModeToolbar.cs b/Client/Assets/Editor/PlayModePlus/PlayModeToolbar.cs new file mode 100644 index 0000000..db579f7 --- /dev/null +++ b/Client/Assets/Editor/PlayModePlus/PlayModeToolbar.cs @@ -0,0 +1,122 @@ +using System.Linq; +using UnityEditor; +using UnityEngine; +using UnityEngine.UIElements; +using YooAsset; + +namespace BuildCli +{ + public class PlayModeToolbar : VisualElement + { + private readonly PlayModeManager _playModeManager = new(); + private readonly BuildManager _buildManager = new(); + + private readonly Button _buildButton; + private readonly DropdownField _selectSceneDropdown; + private readonly DropdownField _selectPlayModeSettingsDropdown; + private readonly DropdownField _selectPlayerSettingsPresetsDropdown; + + public PlayModeToolbar() + { +#if UNITY_6000_0_OR_NEWER + var visualTree = Resources.Load("com.disillusion.play-mode-plus/PlayModePlusToolbar6000"); +#else + var visualTree = Resources.Load("com.disillusion.play-mode-plus/PlayModePlusToolbar"); +#endif + visualTree.CloneTree(this); + + style.flexGrow = 1; + + _buildButton = this.Q