LocalizationComponentInspector.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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(LocalizationComponent))]
  12. internal sealed class LocalizationComponentInspector : GameFrameworkInspector
  13. {
  14. private SerializedProperty m_EnableLoadDictionaryUpdateEvent = null;
  15. private SerializedProperty m_EnableLoadDictionaryDependencyAssetEvent = null;
  16. private SerializedProperty m_CachedBytesSize = null;
  17. private HelperInfo<LocalizationHelperBase> m_LocalizationHelperInfo = new HelperInfo<LocalizationHelperBase>("Localization");
  18. public override void OnInspectorGUI()
  19. {
  20. base.OnInspectorGUI();
  21. serializedObject.Update();
  22. LocalizationComponent t = (LocalizationComponent)target;
  23. EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
  24. {
  25. EditorGUILayout.PropertyField(m_EnableLoadDictionaryUpdateEvent);
  26. EditorGUILayout.PropertyField(m_EnableLoadDictionaryDependencyAssetEvent);
  27. m_LocalizationHelperInfo.Draw();
  28. EditorGUILayout.PropertyField(m_CachedBytesSize);
  29. }
  30. EditorGUI.EndDisabledGroup();
  31. if (EditorApplication.isPlaying && IsPrefabInHierarchy(t.gameObject))
  32. {
  33. EditorGUILayout.LabelField("Language", t.Language.ToString());
  34. EditorGUILayout.LabelField("System Language", t.SystemLanguage.ToString());
  35. EditorGUILayout.LabelField("Dictionary Count", t.DictionaryCount.ToString());
  36. EditorGUILayout.LabelField("Cached Bytes Size", t.CachedBytesSize.ToString());
  37. }
  38. serializedObject.ApplyModifiedProperties();
  39. Repaint();
  40. }
  41. protected override void OnCompileComplete()
  42. {
  43. base.OnCompileComplete();
  44. RefreshTypeNames();
  45. }
  46. private void OnEnable()
  47. {
  48. m_EnableLoadDictionaryUpdateEvent = serializedObject.FindProperty("m_EnableLoadDictionaryUpdateEvent");
  49. m_EnableLoadDictionaryDependencyAssetEvent = serializedObject.FindProperty("m_EnableLoadDictionaryDependencyAssetEvent");
  50. m_CachedBytesSize = serializedObject.FindProperty("m_CachedBytesSize");
  51. m_LocalizationHelperInfo.Init(serializedObject);
  52. RefreshTypeNames();
  53. }
  54. private void RefreshTypeNames()
  55. {
  56. m_LocalizationHelperInfo.Refresh();
  57. serializedObject.ApplyModifiedProperties();
  58. }
  59. }
  60. }