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); }
private static void CallUpdateAction() { try { onUpdate?.Invoke(current.GetFill().GetFillAngle() / 360f); } catch (Exception e) { MelonLogger.Error($"Exception caught in onUpdate action passed to Radial Puppet: {e}"); } }
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); }
public static void OnUpdate() { //Probably a better more efficient way to do all this if (current != null) { if (UnityEngine.XR.XRDevice.isPresent) { if (hand == ActionMenuHand.Right) { if (Input.GetAxis(InputAxes.RightTrigger) >= 0.4) { CloseRadialMenu(); return; } } else if (hand == ActionMenuHand.Left) { if (Input.GetAxis(InputAxes.LeftTrigger) >= 0.4) { CloseRadialMenu(); return; } } } else if (Input.GetMouseButton(0)) { CloseRadialMenu(); return; } UpdateMathStuff(); radialPuppetValue = (current.GetFill().field_Public_Single_3 / 360) * 100; if (onUpdate != null) { onUpdate.Invoke(radialPuppetValue); } } }
public static void UpdateDisplay(this RadialPuppetMenu radialPuppet) { //MelonLogger.Msg($"Original: {radialPuppet.GetFill().field_Public_Single_3}, Math:{(radialPuppet.GetFill().field_Public_Single_3 / 360f)*100f}"); radialPuppet.GetCenterText().text = Math.Round(radialPuppet.GetFill().GetFillAngle() / 360f * 100f) + "%"; radialPuppet.GetFill().UpdateGeometry(); }
public static void SetValue(this RadialPuppetMenu radialPuppet, float value) { radialPuppet.GetFill().SetFillAngle(value / 100 * 360); radialPuppet.UpdateDisplay(); }
public static void SetAngle(this RadialPuppetMenu radialPuppet, float angle) { radialPuppet.GetFill().SetFillAngle(angle); radialPuppet.UpdateDisplay(); }
public static void UpdateDisplay(this RadialPuppetMenu radialPuppet) { radialPuppet.GetCenterText().text = (Math.Round(radialPuppet.GetFill().field_Public_Single_3 / 360 * 100)) + "%"; radialPuppet.GetFill().UpdateGeometry(); }
public static void SetValue(this RadialPuppetMenu radialPuppet, float value) { radialPuppet.GetFill().field_Public_Single_3 = (value / 100) * 360; radialPuppet.UpdateDisplay(); }
public static void SetAngle(this RadialPuppetMenu radialPuppet, float angle) { radialPuppet.GetFill().field_Public_Single_3 = angle; radialPuppet.UpdateDisplay(); }