From 97c7b8cd36dc5f7fa57764dc6605d992bc22d188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=80=9D=E6=B5=B7?= <1464576565@qq.com> Date: Tue, 23 Sep 2025 15:58:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Inspector/ResourceComponentInspector.cs | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Editor/Resource/Inspector/ResourceComponentInspector.cs b/Editor/Resource/Inspector/ResourceComponentInspector.cs index fb50c9c..9202a7a 100644 --- a/Editor/Resource/Inspector/ResourceComponentInspector.cs +++ b/Editor/Resource/Inspector/ResourceComponentInspector.cs @@ -11,6 +11,13 @@ namespace AlicizaX.Resource.Editor [CustomEditor(typeof(ResourceComponent))] internal sealed class ResourceComponentInspector : GameFrameworkInspector { + private static readonly string[] _playModeNames = new string[] + { + "EditorSimulateMode (编辑器下的模拟模式)", + "OfflinePlayMode (单机模式)", + "HostPlayMode (联机运行模式)", + "WebPlayMode (WebGL运行模式)" + }; private SerializedProperty _milliseconds = null; private SerializedProperty _minUnloadUnusedAssetsInterval = null; private SerializedProperty _maxUnloadUnusedAssetsInterval = null; @@ -23,13 +30,13 @@ namespace AlicizaX.Resource.Editor private SerializedProperty _failedTryAgain = null; private SerializedProperty _packageName = null; private SerializedProperty _decryptionServices = null; - private int _packageNameIndex = 0; private string[] _packageNames; private List m_DecryptionServicesTypeName = new(); private int m_DecryptionSelectIndex; + private int _playModeIndex = 0; public override void OnInspectorGUI() { base.OnInspectorGUI(); @@ -38,6 +45,23 @@ namespace AlicizaX.Resource.Editor ResourceComponent t = (ResourceComponent)target; + EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode); + { + if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject)) + { + int index = UnityEditor.EditorPrefs.GetInt(ResourceComponent.PrefsKey, 0); + int selectedIndex = EditorGUILayout.Popup("Play Mode", index, _playModeNames); + } + else + { + int selectedIndex = EditorGUILayout.Popup("Play Mode", _playModeIndex, _playModeNames); + if (selectedIndex != _playModeIndex) + { + _playModeIndex = selectedIndex; + EditorPrefs.SetInt(ResourceComponent.PrefsKey, selectedIndex); + } + } + } m_DecryptionSelectIndex = EditorGUILayout.Popup("解密服务", m_DecryptionSelectIndex, m_DecryptionServicesTypeName.ToArray()); string selectService = m_DecryptionServicesTypeName[m_DecryptionSelectIndex]; if (_decryptionServices.stringValue != selectService)