//------------------------------------------------------------ // Game Framework // Copyright © 2013-2021 loyalsoft. All rights reserved. // Homepage: http://www.game7000.com/ // Feedback: http://www.game7000.com/ //------------------------------------------------------------ using UnityEditor; using UnityGameFramework.Runtime; namespace UnityGameFramework.Editor { [CustomEditor(typeof(SoundComponent))] internal sealed class SoundComponentInspector : GameFrameworkInspector { private SerializedProperty m_EnablePlaySoundUpdateEvent = null; private SerializedProperty m_EnablePlaySoundDependencyAssetEvent = null; private SerializedProperty m_InstanceRoot = null; private SerializedProperty m_AudioMixer = null; private SerializedProperty m_SoundGroups = null; private HelperInfo m_SoundHelperInfo = new HelperInfo("Sound"); private HelperInfo m_SoundGroupHelperInfo = new HelperInfo("SoundGroup"); private HelperInfo m_SoundAgentHelperInfo = new HelperInfo("SoundAgent"); public override void OnInspectorGUI() { base.OnInspectorGUI(); serializedObject.Update(); SoundComponent t = (SoundComponent)target; EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode); { EditorGUILayout.PropertyField(m_EnablePlaySoundUpdateEvent); EditorGUILayout.PropertyField(m_EnablePlaySoundDependencyAssetEvent); EditorGUILayout.PropertyField(m_InstanceRoot); EditorGUILayout.PropertyField(m_AudioMixer); m_SoundHelperInfo.Draw(); m_SoundGroupHelperInfo.Draw(); m_SoundAgentHelperInfo.Draw(); EditorGUILayout.PropertyField(m_SoundGroups, true); } EditorGUI.EndDisabledGroup(); if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject)) { EditorGUILayout.LabelField("Sound Group Count", t.SoundGroupCount.ToString()); } serializedObject.ApplyModifiedProperties(); Repaint(); } protected override void OnCompileComplete() { base.OnCompileComplete(); RefreshTypeNames(); } private void OnEnable() { m_EnablePlaySoundUpdateEvent = serializedObject.FindProperty("m_EnablePlaySoundUpdateEvent"); m_EnablePlaySoundDependencyAssetEvent = serializedObject.FindProperty("m_EnablePlaySoundDependencyAssetEvent"); m_InstanceRoot = serializedObject.FindProperty("m_InstanceRoot"); m_AudioMixer = serializedObject.FindProperty("m_AudioMixer"); m_SoundGroups = serializedObject.FindProperty("m_SoundGroups"); m_SoundHelperInfo.Init(serializedObject); m_SoundGroupHelperInfo.Init(serializedObject); m_SoundAgentHelperInfo.Init(serializedObject); RefreshTypeNames(); } private void RefreshTypeNames() { m_SoundHelperInfo.Refresh(); m_SoundGroupHelperInfo.Refresh(); m_SoundAgentHelperInfo.Refresh(); serializedObject.ApplyModifiedProperties(); } } }