AnimationLinkEditor.cs 694 B

123456789101112131415161718192021222324
  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections.Generic;
  4. namespace Pathfinding {
  5. [CustomEditor(typeof(AnimationLink))]
  6. public class AnimationLinkEditor : Editor {
  7. public override void OnInspectorGUI () {
  8. DrawDefaultInspector();
  9. var script = target as AnimationLink;
  10. EditorGUI.BeginDisabledGroup(script.EndTransform == null);
  11. if (GUILayout.Button("Autoposition Endpoint")) {
  12. List<Vector3> buffer = Pathfinding.Util.ListPool<Vector3>.Claim();
  13. Vector3 endpos;
  14. script.CalculateOffsets(buffer, out endpos);
  15. script.EndTransform.position = endpos;
  16. Pathfinding.Util.ListPool<Vector3>.Release(buffer);
  17. }
  18. EditorGUI.EndDisabledGroup();
  19. }
  20. }
  21. }