Inspector.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace BansheeEngine
  6. {
  7. public class Inspector
  8. {
  9. private GUIElement[] guiElements;
  10. private InspectableObject[] childObjects;
  11. private CustomInspector[] customInspectors;
  12. public Inspector(SceneObject so, GUILayout layout)
  13. {
  14. // TODO - Create SceneObject gui elements (name + transform)
  15. List<CustomInspector> customInspectors = new List<CustomInspector>();
  16. List<InspectableObject> childObjects = new List<InspectableObject>();
  17. Component[] allComponents = so.GetComponents();
  18. for (int i = 0; i < allComponents.Length; i++)
  19. {
  20. // TODO
  21. // - Create component foldout
  22. // - Hook up the foldout so when clicked it will expand/collapse the custom inspector or child object
  23. if (HasCustomInspector(allComponents[i].GetType()))
  24. {
  25. customInspectors.Add(CreateCustomInspector(allComponents[i]));
  26. }
  27. else
  28. {
  29. childObjects.Add(new InspectableObject(allComponents[i]));
  30. }
  31. }
  32. this.customInspectors = customInspectors.ToArray();
  33. this.childObjects = childObjects.ToArray();
  34. }
  35. public void Refresh()
  36. {
  37. for (int i = 0; i < childObjects.Length; i++)
  38. childObjects[i].Refresh();
  39. for (int i = 0; i < customInspectors.Length; i++)
  40. customInspectors[i].Refresh();
  41. }
  42. public void Destroy()
  43. {
  44. // TODO - Destroy SceneObject GUI elements
  45. for (int i = 0; i < childObjects.Length; i++)
  46. childObjects[i].Destroy();
  47. for (int i = 0; i < customInspectors.Length; i++)
  48. customInspectors[i].Destroy();
  49. }
  50. private bool HasCustomInspector(Type type)
  51. {
  52. // TODO - Check if Component (or some other type) has a custom inspector
  53. return false;
  54. }
  55. private CustomInspector CreateCustomInspector(Component component)
  56. {
  57. // Find and create a custom inspector
  58. return null;
  59. }
  60. // TODO - Ensure all GUI elements are properly cleaned up when this is destroyed
  61. }
  62. }