private static void UpdateMathStuff() { var mousePos = hand == ActionMenuHand.Left ? Utilities.GetCursorPosLeft() : Utilities.GetCursorPosRight(); radialPuppetMenuRight.GetCursor().transform.localPosition = mousePos * 4; if (Vector2.Distance(mousePos, Vector2.zero) > 12) { var angleOriginal = Mathf.Round(Mathf.Atan2(mousePos.y, mousePos.x) * Constants.RAD_TO_DEG); var eulerAngle = Utilities.ConvertFromDegToEuler(angleOriginal); var normalisedAngle = eulerAngle / 360f; if (Math.Abs(normalisedAngle - currentValue) < 0.0001f) { return; } if (!restricted) { current.SetAngle(eulerAngle); current.UpdateArrow(angleOriginal, eulerAngle); } else { if (currentValue > normalisedAngle) { if (currentValue - normalisedAngle < 0.5f) { current.SetAngle(eulerAngle); current.UpdateArrow(angleOriginal, eulerAngle); currentValue = normalisedAngle; } else { current.SetAngle(360); current.UpdateArrow(90, 360); currentValue = 1f; } } else { if (normalisedAngle - currentValue < 0.5f) { current.SetAngle(eulerAngle); current.UpdateArrow(angleOriginal, eulerAngle); currentValue = normalisedAngle; } else { current.SetAngle(0); current.UpdateArrow(90, 0); currentValue = 0; } } } } }
private static void UpdateMathStuff() { Vector2 mousePos = (hand == ActionMenuHand.Left) ? Utilities.GetCursorPosLeft() : Utilities.GetCursorPosRight(); radialPuppetMenuRight.GetCursor().transform.localPosition = mousePos * 4; if (Vector2.Distance(mousePos, Vector2.zero) > 12) { double angleOriginal = Math.Round(((float)Math.Atan2(mousePos.y, mousePos.x)) * Constants.radToDeg); double eulerAngle = Utilities.ConvertFromDegToEuler(angleOriginal); current.SetAngle((float)eulerAngle); current.UpdateArrow(angleOriginal, eulerAngle); } }
public static void OpenRadialMenu(float startingValue, Action <float> onUpdate, string title, PedalOption pedalOption, bool restricted = false) { if (open) { return; } switch (Utilities.GetActionMenuHand()) { case ActionMenuHand.Invalid: return; case ActionMenuHand.Left: current = radialPuppetMenuLeft; hand = ActionMenuHand.Left; open = true; break; case ActionMenuHand.Right: current = radialPuppetMenuRight; hand = ActionMenuHand.Right; open = true; break; } RadialPuppetManager.restricted = restricted; Input.ResetInputAxes(); current.gameObject.SetActive(true); current.GetFill().SetFillAngle(startingValue * 360); //Please dont break RadialPuppetManager.onUpdate = onUpdate; currentValue = startingValue; current.GetTitle().text = title; current.GetCenterText().text = $"{Mathf.Round(startingValue * 100f)}%"; current.GetFill().UpdateGeometry(); ; current.transform.localPosition = pedalOption.GetActionButton().transform.localPosition; //new Vector3(-256f, 0, 0); var angleOriginal = Utilities.ConvertFromEuler(startingValue * 360); var eulerAngle = Utilities.ConvertFromDegToEuler(angleOriginal); current.UpdateArrow(angleOriginal, eulerAngle); }
public static void OpenRadialMenu(float startingValue, Action <float> close, string title) { if (open) { return; } switch (Utilities.GetActionMenuHand()) { case ActionMenuHand.Invalid: return; case ActionMenuHand.Left: current = radialPuppetMenuLeft; hand = ActionMenuHand.Left; open = true; break; case ActionMenuHand.Right: current = radialPuppetMenuRight; hand = ActionMenuHand.Right; open = true; break; } Input.ResetInputAxes(); onClose = close; current.gameObject.SetActive(true); current.GetFill().field_Public_Single_3 = startingValue; onUpdate = onClose; current.GetTitle().text = title; current.GetCenterText().text = (Math.Round(radialPuppetMenuRight.GetFill().field_Public_Single_3 / 360 * 100)) + "%"; current.GetFill().UpdateGeometry(); current.transform.localPosition = new Vector3(-256f, 0, 0); double angleOriginal = (startingValue / 100) * 360; double eulerAngle = Utilities.ConvertFromDegToEuler(angleOriginal); current.UpdateArrow(angleOriginal, eulerAngle); }