Mouse Released this Frame#
Input / Mouse Released this Frame
Can Read
Cannot Write
Description#
Returns true the frame the specified Mouse button is released
Parameters#
| Name | Description |
|---|---|
| Button | The Mouse button that is checked |
Code#
using System;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.LowLevel;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Inline(nameof(m_Button))]
[Title("Mouse Released this Frame")]
[Category("Input/Mouse Released this Frame")]
[Description("Returns true the frame the specified Mouse button is released")]
[Image(typeof(IconMouseUp), ColorTheme.Type.Blue)]
[Parameter("Button", "The Mouse button that is checked")]
[Keywords("Left", "Right", "Middle", "Cursor", "Up", "Just", "Click")]
[Serializable]
public class TypeBoolInputMouseReleaseThisFrame : TypeBool
{
[SerializeField] private MouseButton m_Button = MouseButton.Left;
public override bool Get(Args args)
{
Mouse mouse = Mouse.current;
if (mouse == null) return false;
ButtonControl button = this.m_Button switch
{
MouseButton.Left => mouse.leftButton,
MouseButton.Right => mouse.rightButton,
MouseButton.Middle => mouse.middleButton,
MouseButton.Forward => mouse.forwardButton,
MouseButton.Back => mouse.backButton,
_ => throw new ArgumentOutOfRangeException()
};
return button.wasReleasedThisFrame;
}
public override string ToString()
{
return $"Released Mouse {this.m_Button}";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}