/// <summary> /// Creates GUI elements for fields specific to the capsule collider. /// </summary> protected void BuildGUI(CapsuleCollider collider) { centerField.OnChanged += x => { collider.Center = x; MarkAsModified(); }; centerField.OnFocusLost += ConfirmModify; centerField.OnConfirmed += ConfirmModify; orientationField.OnChanged += x => { orientation = x; Quaternion rotation = Quaternion.FromEuler(x); collider.Normal = rotation.Rotate(Vector3.YAxis); MarkAsModified(); }; orientationField.OnFocusLost += ConfirmModify; orientationField.OnConfirmed += ConfirmModify; radiusField.OnChanged += x => { collider.Radius = x; MarkAsModified(); }; radiusField.OnFocusLost += ConfirmModify; radiusField.OnConfirmed += ConfirmModify; halfHeightField.OnChanged += x => { collider.HalfHeight = x; MarkAsModified(); }; halfHeightField.OnFocusLost += ConfirmModify; halfHeightField.OnConfirmed += ConfirmModify; Layout.AddElement(centerField); Layout.AddElement(orientationField); Layout.AddElement(radiusField); Layout.AddElement(halfHeightField); orientation = Quaternion.FromToRotation(Vector3.YAxis, collider.Normal).ToEuler(); base.BuildGUI(collider); }
/// <summary> /// Updates all GUI elements from current values in the collider. /// </summary> /// <param name="collider">Collider to update the GUI from.</param> protected void Refresh(CapsuleCollider collider) { if (!centerField.HasInputFocus) centerField.Value = collider.Center; if (!orientationField.HasInputFocus) orientationField.Value = orientation; if (!radiusField.HasInputFocus) radiusField.Value = collider.Radius; if (!halfHeightField.HasInputFocus) halfHeightField.Value = collider.HalfHeight; base.Refresh(collider); }