No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GenericDefaultControl.cs 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using System;
  2. using UnityEngine;
  3. namespace UnityEditor.U2D.Path.GUIFramework
  4. {
  5. /// <summary>
  6. /// Represents a default generic UI control.
  7. /// </summary>
  8. public class GenericDefaultControl : DefaultControl
  9. {
  10. /// <summary>
  11. /// Func for GetPosition
  12. /// </summary>
  13. public Func<IGUIState, Vector3> position;
  14. /// <summary>
  15. /// Func for GetForward
  16. /// </summary>
  17. public Func<IGUIState, Vector3> forward;
  18. /// <summary>
  19. /// Func for GetUp
  20. /// </summary>
  21. public Func<IGUIState, Vector3> up;
  22. /// <summary>
  23. /// Func for GetRight
  24. /// </summary>
  25. public Func<IGUIState, Vector3> right;
  26. /// <summary>
  27. /// Func for GetUserData
  28. /// </summary>
  29. public Func<IGUIState, object> userData;
  30. /// <summary>
  31. /// Initializes and returns an instance of GenericDefaultControl
  32. /// </summary>
  33. /// <param name="name">The name of the generic default control.</param>
  34. public GenericDefaultControl(string name) : base(name)
  35. {
  36. }
  37. /// <summary>
  38. /// Gets the distance from the Scene view camera to the control.
  39. /// </summary>
  40. /// <param name="guiState">The current state of the custom editor.</param>
  41. /// <param name="index">The Index</param>
  42. /// <returns>The distance from the Scene view camera to the control.</returns>
  43. protected override Vector3 GetPosition(IGUIState guiState, int index)
  44. {
  45. if (position != null)
  46. return position(guiState);
  47. return base.GetPosition(guiState, index);
  48. }
  49. /// <summary>
  50. /// Gets the forward vector of the control.
  51. /// </summary>
  52. /// <param name="guiState">The current state of the custom editor.</param>
  53. /// <param name="index">The Index</param>
  54. /// <returns>Returns the generic control's forward vector.</returns>
  55. protected override Vector3 GetForward(IGUIState guiState, int index)
  56. {
  57. if (forward != null)
  58. return forward(guiState);
  59. return base.GetForward(guiState, index);
  60. }
  61. /// <summary>
  62. /// Gets the up vector of the control.
  63. /// </summary>
  64. /// <param name="guiState">The current state of the custom editor.</param>
  65. /// <param name="index">The Index</param>
  66. /// <returns>Returns the generic control's up vector.</returns>
  67. protected override Vector3 GetUp(IGUIState guiState, int index)
  68. {
  69. if (up != null)
  70. return up(guiState);
  71. return base.GetUp(guiState, index);
  72. }
  73. /// <summary>
  74. /// Gets the right vector of the control.
  75. /// </summary>
  76. /// <param name="guiState">The current state of the custom editor.</param>
  77. /// <param name="index">The Index</param>
  78. /// <returns>Returns the generic control's right vector.</returns>
  79. protected override Vector3 GetRight(IGUIState guiState, int index)
  80. {
  81. if (right != null)
  82. return right(guiState);
  83. return base.GetRight(guiState, index);
  84. }
  85. /// <summary>
  86. /// Gets the control's user data.
  87. /// </summary>
  88. /// <param name="guiState">The current state of the custom editor.</param>
  89. /// <param name="index">The Index</param>
  90. /// <returns>Returns the user data</returns>
  91. protected override object GetUserData(IGUIState guiState, int index)
  92. {
  93. if (userData != null)
  94. return userData(guiState);
  95. return base.GetUserData(guiState, index);
  96. }
  97. }
  98. }