using System; using UnityEngine; namespace UnityEditor.U2D.Path.GUIFramework { /// /// Represents a default generic UI control. /// public class GenericDefaultControl : DefaultControl { /// /// Func for GetPosition /// public Func position; /// /// Func for GetForward /// public Func forward; /// /// Func for GetUp /// public Func up; /// /// Func for GetRight /// public Func right; /// /// Func for GetUserData /// public Func userData; /// /// Initializes and returns an instance of GenericDefaultControl /// /// The name of the generic default control. public GenericDefaultControl(string name) : base(name) { } /// /// Gets the distance from the Scene view camera to the control. /// /// The current state of the custom editor. /// The Index /// The distance from the Scene view camera to the control. protected override Vector3 GetPosition(IGUIState guiState, int index) { if (position != null) return position(guiState); return base.GetPosition(guiState, index); } /// /// Gets the forward vector of the control. /// /// The current state of the custom editor. /// The Index /// Returns the generic control's forward vector. protected override Vector3 GetForward(IGUIState guiState, int index) { if (forward != null) return forward(guiState); return base.GetForward(guiState, index); } /// /// Gets the up vector of the control. /// /// The current state of the custom editor. /// The Index /// Returns the generic control's up vector. protected override Vector3 GetUp(IGUIState guiState, int index) { if (up != null) return up(guiState); return base.GetUp(guiState, index); } /// /// Gets the right vector of the control. /// /// The current state of the custom editor. /// The Index /// Returns the generic control's right vector. protected override Vector3 GetRight(IGUIState guiState, int index) { if (right != null) return right(guiState); return base.GetRight(guiState, index); } /// /// Gets the control's user data. /// /// The current state of the custom editor. /// The Index /// Returns the user data protected override object GetUserData(IGUIState guiState, int index) { if (userData != null) return userData(guiState); return base.GetUserData(guiState, index); } } }