How does one use the brand new enter system to find out the states:
- Contact Ended
- Pen Lifted
- Mouse Up
I’ve tried subscribing to canceled (is not at all times triggered, appears to false set off). There doesn’t appear to be an ended?
utilizing UnityEngine;
utilizing UnityEngine.InputSystem;
public class InputEndDetector : MonoBehaviour
{
personal static bool hasInputEnded = false;
personal PlayerControls playerControls;
personal InputAction pointerAction;
personal void Awake()
{
playerControls = new PlayerControls();
pointerAction = playerControls.NewActionMap.Pointer;
pointerAction.canceled += OnPointerEnded; // Hear for the canceled occasion
}
personal void OnEnable()
{
pointerAction.Allow();
}
personal void OnDisable()
{
pointerAction.Disable();
}
personal void OnPointerEnded(InputAction.CallbackContext context)
{
if (context.canceled)
{
Debug.Log("Pointer lifted or ended");
hasInputEnded = true;
}
}
public static bool HasInputEnded()
{
bool x = hasInputEnded;
hasInputEnded = false;
return x;
}
}
//------------------------------------------------------------------------------
//
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
// model 1.7.0
// from Belongings/Core/Enter/PlayerControls.inputactions
//
// Adjustments to this file might trigger incorrect habits and shall be misplaced if
// the code is regenerated.
//
//------------------------------------------------------------------------------
utilizing System;
utilizing System.Collections;
utilizing System.Collections.Generic;
utilizing UnityEngine.InputSystem;
utilizing UnityEngine.InputSystem.Utilities;
public partial class @PlayerControls: IInputActionCollection2, IDisposable
{
public InputActionAsset asset { get; }
public @PlayerControls()
{
asset = InputActionAsset.FromJson(@"{
""identify"": ""PlayerControls"",
""maps"": [
{
""name"": ""NewActionMap"",
""id"": ""4075ce87-7790-4f43-bafa-e80dea298f8d"",
""actions"": [
{
""name"": ""Pointer"",
""type"": ""Button"",
""id"": ""9ae9dda6-f644-4e18-992e-4ef4f0712423"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
}
],
""bindings"": [
{
""name"": """",
""id"": ""dab7977f-e958-40fc-94cc-7d4fa6f90a65"",
""path"": ""Pen/PenContact"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Pointer"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""dbdbf34f-3af8-43f3-beab-67112bb1771d"",
""path"": ""Touchscreen/primaryTouch/press"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Pointer"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""1dd51653-af24-4e16-bd45-5ec5e8cef172"",
""path"": ""Mouse/leftButton"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Pointer"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""98ff3390-6756-4307-bba5-44364121b1b6"",
""path"": ""*/{PrimaryAction}"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Pointer"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}
],
""controlSchemes"": []
}");
// NewActionMap
m_NewActionMap = asset.FindActionMap("NewActionMap", throwIfNotFound: true);
m_NewActionMap_Pointer = m_NewActionMap.FindAction("Pointer", throwIfNotFound: true);
}
public void Dispose()
{
UnityEngine.Object.Destroy(asset);
}
public InputBinding? bindingMask
{
get => asset.bindingMask;
set => asset.bindingMask = worth;
}
public ReadOnlyArray? units
{
get => asset.units;
set => asset.units = worth;
}
public ReadOnlyArray controlSchemes => asset.controlSchemes;
public bool Accommodates(InputAction motion)
{
return asset.Accommodates(motion);
}
public IEnumerator GetEnumerator()
{
return asset.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public void Allow()
{
asset.Allow();
}
public void Disable()
{
asset.Disable();
}
public IEnumerable bindings => asset.bindings;
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
{
return asset.FindAction(actionNameOrId, throwIfNotFound);
}
public int FindBinding(InputBinding bindingMask, out InputAction motion)
{
return asset.FindBinding(bindingMask, out motion);
}
// NewActionMap
personal readonly InputActionMap m_NewActionMap;
personal Listing m_NewActionMapActionsCallbackInterfaces = new Listing();
personal readonly InputAction m_NewActionMap_Pointer;
public struct NewActionMapActions
{
personal @PlayerControls m_Wrapper;
public NewActionMapActions(@PlayerControls wrapper) { m_Wrapper = wrapper; }
public InputAction @Pointer => m_Wrapper.m_NewActionMap_Pointer;
public InputActionMap Get() { return m_Wrapper.m_NewActionMap; }
public void Allow() { Get().Allow(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(NewActionMapActions set) { return set.Get(); }
public void AddCallbacks(INewActionMapActions occasion)
personal void UnregisterCallbacks(INewActionMapActions occasion)
{
@Pointer.began -= occasion.OnPointer;
@Pointer.carried out -= occasion.OnPointer;
@Pointer.canceled -= occasion.OnPointer;
}
public void RemoveCallbacks(INewActionMapActions occasion)
{
if (m_Wrapper.m_NewActionMapActionsCallbackInterfaces.Take away(occasion))
UnregisterCallbacks(occasion);
}
public void SetCallbacks(INewActionMapActions occasion)
{
foreach (var merchandise in m_Wrapper.m_NewActionMapActionsCallbackInterfaces)
UnregisterCallbacks(merchandise);
m_Wrapper.m_NewActionMapActionsCallbackInterfaces.Clear();
AddCallbacks(occasion);
}
}
public NewActionMapActions @NewActionMap => new NewActionMapActions(this);
public interface INewActionMapActions
{
void OnPointer(InputAction.CallbackContext context);
}
}
```