123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- //------------------------------------------------------------
- // Game Framework
- // Copyright © 2013-2021 loyalsoft. All rights reserved.
- // Homepage: http://www.game7000.com/
- // Feedback: http://www.game7000.com/
- //------------------------------------------------------------
- using GameFramework;
- using GameFramework.DataTable;
- using UnityEditor;
- using UnityGameFramework.Runtime;
- namespace UnityGameFramework.Editor
- {
- [CustomEditor(typeof(DataTableComponent))]
- internal sealed class DataTableComponentInspector : GameFrameworkInspector
- {
- private SerializedProperty m_EnableLoadDataTableUpdateEvent = null;
- private SerializedProperty m_EnableLoadDataTableDependencyAssetEvent = null;
- private SerializedProperty m_CachedBytesSize = null;
- private HelperInfo<DataTableHelperBase> m_DataTableHelperInfo = new HelperInfo<DataTableHelperBase>("DataTable");
- public override void OnInspectorGUI()
- {
- base.OnInspectorGUI();
- serializedObject.Update();
- DataTableComponent t = (DataTableComponent)target;
- EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
- {
- EditorGUILayout.PropertyField(m_EnableLoadDataTableUpdateEvent);
- EditorGUILayout.PropertyField(m_EnableLoadDataTableDependencyAssetEvent);
- m_DataTableHelperInfo.Draw();
- EditorGUILayout.PropertyField(m_CachedBytesSize);
- }
- EditorGUI.EndDisabledGroup();
- if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject))
- {
- EditorGUILayout.LabelField("Data Table Count", t.Count.ToString());
- EditorGUILayout.LabelField("Cached Bytes Size", t.CachedBytesSize.ToString());
- DataTableBase[] dataTables = t.GetAllDataTables();
- foreach (DataTableBase dataTable in dataTables)
- {
- DrawDataTable(dataTable);
- }
- }
- serializedObject.ApplyModifiedProperties();
- Repaint();
- }
- protected override void OnCompileComplete()
- {
- base.OnCompileComplete();
- RefreshTypeNames();
- }
- private void OnEnable()
- {
- m_EnableLoadDataTableUpdateEvent = serializedObject.FindProperty("m_EnableLoadDataTableUpdateEvent");
- m_EnableLoadDataTableDependencyAssetEvent = serializedObject.FindProperty("m_EnableLoadDataTableDependencyAssetEvent");
- m_CachedBytesSize = serializedObject.FindProperty("m_CachedBytesSize");
- m_DataTableHelperInfo.Init(serializedObject);
- RefreshTypeNames();
- }
- private void DrawDataTable(DataTableBase dataTable)
- {
- EditorGUILayout.LabelField(dataTable.FullName, Utility.Text.Format("{0} Rows", dataTable.Count.ToString()));
- }
- private void RefreshTypeNames()
- {
- m_DataTableHelperInfo.Refresh();
- serializedObject.ApplyModifiedProperties();
- }
- }
- }
|