VFXTransformGizmos.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using UnityEngine;
  6. using UnityEngine.VFX;
  7. namespace UnityEditor.VFX
  8. {
  9. [VFXGizmo(typeof(Transform))]
  10. class VFXTransformGizmo : VFXSpaceableGizmo<Transform>
  11. {
  12. IProperty<Vector3> m_PositionProperty;
  13. IProperty<Vector3> m_AnglesProperty;
  14. IProperty<Vector3> m_ScaleProperty;
  15. public override void RegisterEditableMembers(IContext context)
  16. {
  17. m_PositionProperty = context.RegisterProperty<Vector3>("position");
  18. m_AnglesProperty = context.RegisterProperty<Vector3>("angles");
  19. m_ScaleProperty = context.RegisterProperty<Vector3>("scale");
  20. }
  21. public override void OnDrawSpacedGizmo(Transform transform)
  22. {
  23. PositionGizmo(transform.position, transform.angles, m_PositionProperty, false);
  24. RotationGizmo(transform.position, transform.angles, m_AnglesProperty, false);
  25. ScaleGizmo(transform.position, transform.scale, Quaternion.Euler(transform.angles), m_ScaleProperty, false);
  26. }
  27. public override Bounds OnGetSpacedGizmoBounds(Transform value)
  28. {
  29. return new Bounds(value.position, value.scale); //TODO take orientation in account
  30. }
  31. }
  32. }