GizmosMatrix.cs 876 B

123456789101112131415161718192021222324252627282930313233343536
  1. #if UNITY_EDITOR
  2. using UnityEngine;
  3. using System.Collections.Generic;
  4. namespace O3DWB
  5. {
  6. public static class GizmosMatrix
  7. {
  8. #region Private Static Variables
  9. private static Matrix4x4 _initialMatrix = Matrix4x4.identity;
  10. private static Stack<Matrix4x4> _matrixStack = new Stack<Matrix4x4>();
  11. #endregion
  12. #region Constructors
  13. static GizmosMatrix()
  14. {
  15. _matrixStack.Push(_initialMatrix);
  16. }
  17. #endregion
  18. #region Public Methods
  19. public static void Push(Matrix4x4 matrix)
  20. {
  21. _matrixStack.Push(matrix);
  22. Gizmos.matrix = _matrixStack.Peek();
  23. }
  24. public static void Pop()
  25. {
  26. if (_matrixStack.Count > 1) _matrixStack.Pop();
  27. Gizmos.matrix = _matrixStack.Peek();
  28. }
  29. #endregion
  30. }
  31. }
  32. #endif