Unity 框架

TEditor.cs 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. using UnityEditor.SceneManagement;
  6. namespace TFramework
  7. {
  8. public class TEditor : Editor
  9. {
  10. /// <summary>
  11. /// 控件标签标准宽度
  12. /// </summary>
  13. protected virtual float LabelWidth=> EditorGUIUtility.labelWidth;
  14. /// <summary>
  15. /// 标记场景中值被改变
  16. /// </summary>
  17. public void MarkerChange()
  18. {
  19. EditorUtility.SetDirty(target);
  20. if (EditorApplication.isPlaying) return;
  21. Component component = target as Component;
  22. if (component != null && component.gameObject.scene != null)
  23. {
  24. EditorSceneManager.MarkSceneDirty(component.gameObject.scene);
  25. }
  26. }
  27. public void DrawGUICopyButon(Rect rect,string v)
  28. {
  29. if (GUI.Button(rect,"复制"))
  30. {
  31. EditorGUIUtility.systemCopyBuffer = v;
  32. }
  33. }
  34. public void DrawGUILayoutCopyButton(string v)
  35. {
  36. if (GUILayout.Button("复制", GUILayout.ExpandWidth(false)))
  37. {
  38. EditorGUIUtility.systemCopyBuffer = v;
  39. }
  40. }
  41. }
  42. }