UIKitHierarchyMenu.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /****************************************************************************
  2. * Copyright (c) 2017 ~ 2021.8 liangxiegame MIT License
  3. *
  4. * http://qframework.io
  5. * https://github.com/liangxiegame/QFramework
  6. ****************************************************************************/
  7. using System.Linq;
  8. using UnityEditor;
  9. using UnityEditor.SceneManagement;
  10. using UnityEngine;
  11. namespace QFramework
  12. {
  13. public static class UIKitHierarchyMenu
  14. {
  15. [MenuItem("GameObject/@UI Kit - Add Bind (alt + b) &b",false,-1)]
  16. public static void AddBind()
  17. {
  18. foreach (var o in Selection.objects.OfType<GameObject>())
  19. {
  20. if (o)
  21. {
  22. var uiMark = o.GetComponent<Bind>();
  23. if (!uiMark)
  24. {
  25. o.AddComponent<Bind>();
  26. }
  27. EditorUtility.SetDirty(o);
  28. EditorSceneManager.MarkSceneDirty(o.scene);
  29. }
  30. }
  31. }
  32. }
  33. }