DataNodeComponentInspector.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 GameFramework.DataNode;
  8. using UnityEditor;
  9. using UnityGameFramework.Runtime;
  10. namespace UnityGameFramework.Editor
  11. {
  12. [CustomEditor(typeof(DataNodeComponent))]
  13. internal sealed class DataNodeComponentInspector : GameFrameworkInspector
  14. {
  15. public override void OnInspectorGUI()
  16. {
  17. base.OnInspectorGUI();
  18. if (!EditorApplication.isPlaying)
  19. {
  20. EditorGUILayout.HelpBox("Available during runtime only.", MessageType.Info);
  21. return;
  22. }
  23. DataNodeComponent t = (DataNodeComponent)target;
  24. if (IsPrefabInHierarchy(t.gameObject))
  25. {
  26. DrawDataNode(t.Root);
  27. }
  28. Repaint();
  29. }
  30. private void OnEnable()
  31. {
  32. }
  33. private void DrawDataNode(IDataNode dataNode)
  34. {
  35. EditorGUILayout.LabelField(dataNode.FullName, dataNode.ToDataString());
  36. IDataNode[] child = dataNode.GetAllChild();
  37. foreach (IDataNode c in child)
  38. {
  39. DrawDataNode(c);
  40. }
  41. }
  42. }
  43. }