ConfigComponentInspector.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //------------------------------------------------------------
  2. // Game Framework
  3. // Copyright © 2013-2021 loyalsoft. All rights reserved.
  4. // Homepage: http://www.game7000.com/
  5. // Feedback: http://www.game7000.com/
  6. //------------------------------------------------------------
  7. using UnityEditor;
  8. using UnityGameFramework.Runtime;
  9. namespace UnityGameFramework.Editor
  10. {
  11. [CustomEditor(typeof(ConfigComponent))]
  12. internal sealed class ConfigComponentInspector : GameFrameworkInspector
  13. {
  14. private SerializedProperty m_EnableLoadConfigUpdateEvent = null;
  15. private SerializedProperty m_EnableLoadConfigDependencyAssetEvent = null;
  16. private SerializedProperty m_CachedBytesSize = null;
  17. private HelperInfo<ConfigHelperBase> m_ConfigHelperInfo = new HelperInfo<ConfigHelperBase>("Config");
  18. public override void OnInspectorGUI()
  19. {
  20. base.OnInspectorGUI();
  21. serializedObject.Update();
  22. ConfigComponent t = (ConfigComponent)target;
  23. EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
  24. {
  25. EditorGUILayout.PropertyField(m_EnableLoadConfigUpdateEvent);
  26. EditorGUILayout.PropertyField(m_EnableLoadConfigDependencyAssetEvent);
  27. m_ConfigHelperInfo.Draw();
  28. EditorGUILayout.PropertyField(m_CachedBytesSize);
  29. }
  30. EditorGUI.EndDisabledGroup();
  31. if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject))
  32. {
  33. EditorGUILayout.LabelField("Config Count", t.Count.ToString());
  34. EditorGUILayout.LabelField("Cached Bytes Size", t.CachedBytesSize.ToString());
  35. }
  36. serializedObject.ApplyModifiedProperties();
  37. Repaint();
  38. }
  39. protected override void OnCompileComplete()
  40. {
  41. base.OnCompileComplete();
  42. RefreshTypeNames();
  43. }
  44. private void OnEnable()
  45. {
  46. m_EnableLoadConfigUpdateEvent = serializedObject.FindProperty("m_EnableLoadConfigUpdateEvent");
  47. m_EnableLoadConfigDependencyAssetEvent = serializedObject.FindProperty("m_EnableLoadConfigDependencyAssetEvent");
  48. m_CachedBytesSize = serializedObject.FindProperty("m_CachedBytesSize");
  49. m_ConfigHelperInfo.Init(serializedObject);
  50. RefreshTypeNames();
  51. }
  52. private void RefreshTypeNames()
  53. {
  54. m_ConfigHelperInfo.Refresh();
  55. serializedObject.ApplyModifiedProperties();
  56. }
  57. }
  58. }