EasytouchHierachyCallBack.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // EasyTouch library is copyright (c) of Hedgehog Team
  2. // Please send feedback or bug reports to the.hedgehog.team@gmail.com
  3. using UnityEngine;
  4. using UnityEditor;
  5. using System;
  6. using HedgehogTeam.EasyTouch;
  7. [InitializeOnLoad]
  8. public class EasytouchHierachyCallBack{
  9. private static readonly EditorApplication.HierarchyWindowItemCallback hiearchyItemCallback;
  10. private static Texture2D hierarchyIcon;
  11. private static Texture2D HierarchyIcon {
  12. get {
  13. if (EasytouchHierachyCallBack.hierarchyIcon==null){
  14. EasytouchHierachyCallBack.hierarchyIcon = (Texture2D)Resources.Load( "EasyTouch_Icon");
  15. }
  16. return EasytouchHierachyCallBack.hierarchyIcon;
  17. }
  18. }
  19. private static Texture2D hierarchyEventIcon;
  20. private static Texture2D HierarchyEventIcon {
  21. get {
  22. if (EasytouchHierachyCallBack.hierarchyEventIcon==null){
  23. EasytouchHierachyCallBack.hierarchyEventIcon = (Texture2D)Resources.Load( "EasyTouchTrigger_Icon");
  24. }
  25. return EasytouchHierachyCallBack.hierarchyEventIcon;
  26. }
  27. }
  28. // constructor
  29. static EasytouchHierachyCallBack()
  30. {
  31. EasytouchHierachyCallBack.hiearchyItemCallback = new EditorApplication.HierarchyWindowItemCallback(EasytouchHierachyCallBack.DrawHierarchyIcon);
  32. EditorApplication.hierarchyWindowItemOnGUI = (EditorApplication.HierarchyWindowItemCallback)Delegate.Combine(EditorApplication.hierarchyWindowItemOnGUI, EasytouchHierachyCallBack.hiearchyItemCallback);
  33. }
  34. private static void DrawHierarchyIcon(int instanceID, Rect selectionRect)
  35. {
  36. GameObject gameObject = EditorUtility.InstanceIDToObject(instanceID) as GameObject;
  37. if (gameObject != null){
  38. Rect rect = new Rect(selectionRect.x + selectionRect.width - 16f, selectionRect.y, 16f, 16f);
  39. if ( gameObject.GetComponent<EasyTouch>() != null){
  40. GUI.DrawTexture( rect,EasytouchHierachyCallBack.HierarchyIcon);
  41. }
  42. else if (gameObject.GetComponent<QuickBase>() != null){
  43. GUI.DrawTexture( rect,EasytouchHierachyCallBack.HierarchyEventIcon);
  44. }
  45. #if FALSE
  46. else if (gameObject.GetComponent<EasyTouchSceneProxy>() != null){
  47. GUI.DrawTexture( rect,EasytouchHierachyCallBack.HierarchyIcon);
  48. }
  49. #endif
  50. }
  51. }
  52. }