unity3d Unity新输入系统触摸菜单-错误

m528fe3b  于 2023-01-26  发布在  其他
关注(0)|答案(1)|浏览(212)

I'm making a Game with Touch, Controller and Keyboard Input with the NEW InputSystem 1.0.2
If the game is currently running and the StartButton will be pressed, then the TouchUI should disappear and PauseMenu should appear. Currently it shows me the error messages. This only happens in the TouchUICanvas environment. Works perfectly fine with gamepad and keyboard.
Everything works.

ErrorWarnings: by pressing with Touch on the StartButton(TouchUICanvas)

-Assertionfailed UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType,NativeInputEventBuffer*) UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType,IntPtr)(at/Users/builduser/buildslave/unity/build/Modules/Input/Private/Input.cs:120)
-ArgumentOutOfRangeExceptionduringeventprocessingofDynamicupdate;resettingeventbuffer UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType,NativeInputEventBuffer*) UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType,IntPtr)(at/Users/builduser/buildslave/unity/build/Modules/Input/Private/Input.cs:120)
-ArgumentOutOfRangeException:Specifiedargumentwasoutoftherangeofvalidvalues. Parametername:index UnityEngine.InputSystem.Utilities.InlinedArray`1[TValue].get_Item(System.Int32index)(atLibrary/PackageCache/com.unity.inputsystem@1.0.2/InputSystem/Utilities/InlinedArray.cs:68) UnityEngine.InputSystem.DynamicBitfield.ClearBit(System.Int32bitIndex)(atLibrary/PackageCache/com.unity.inputsystem@1.0.2/InputSystem/Utilities/DynamicBitfield.cs:51) UnityEngine.InputSystem.InputManager.FireStateChangeNotifications(System.Int32deviceIndex,System.DoubleinternalTime,UnityEngine.InputSystem.LowLevel.InputEventeventPtr)(atLibrary/PackageCache/com.unity.inputsystem@1.0.2/InputSystem/InputManager.cs:2924) UnityEngine.InputSystem.InputManager.UpdateState(UnityEngine.InputSystem.InputDevicedevice,UnityEngine.InputSystem.LowLevel.InputUpdateTypeupdateType,System.VoidstatePtr,System.UInt32stateOffsetInDevice,System.UInt32stateSize,System.DoubleinternalTime,UnityEngine.InputSystem.LowLevel.InputEventPtreventPtr)(atLibrary/PackageCache/com.unity.inputsystem@1.0.2/InputSystem/InputManager.cs:3101) UnityEngine.InputSystem.InputManager.UpdateState(UnityEngine.InputSystem.InputDevicedevice,UnityEngine.InputSystem.LowLevel.InputEventeventPtr,UnityEngine.InputSystem.LowLevel.InputUpdateTypeupdateType)(atLibrary/PackageCache/com.unity.inputsystem@1.0.2/InputSystem/InputManager.cs:3017) UnityEngine.InputSystem.InputManager.OnUpdate(UnityEngine.InputSystem.LowLevel.InputUpdateTypeupdateType,UnityEngine.InputSystem.LowLevel.InputEventBuffer&eventBuffer)(atLibrary/PackageCache/com.unity.inputsystem@1.0.2/InputSystem/InputManager.cs:2707) UnityEngine.InputSystem.LowLevel.NativeInputRuntime+<>c__DisplayClass7_0.<set_onUpdate>b__0(UnityEngineInternal.Input.NativeInputUpdateTypeupdateType,UnityEngineInternal.Input.NativeInputEventBuffereventBufferPtr)(atLibrary/PackageCache/com.unity.inputsystem@1.0.2/InputSystem/NativeInputRuntime.cs:64) UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType,NativeInputEventBuffer*) UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType,IntPtr)(at/Users/builduser/buildslave/unity/build/Modules/Input/Private/Input.cs:120)

These 2 Error-Codes Appeared after I pressed with Touch - on the ResumeButton(pauseScreen) with the function PauseUnpause().

-Action has been triggered but apparently not from an interaction yet there's interactions on the binding that got triggered?!?
UnityEngine.GameObject:SetActive(Boolean) OverworldPauseMenu:PauseUnpause() (at Assets/OverworldPauseMenu.cs:47) UnityEngine.EventSystems.EventSystem:Update() (at /Applications/Unity/Hub/Editor/2019.3.15f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)
-Control index out of range UnityEngine.GameObject:SetActive(Boolean) OverworldPauseMenu:PauseUnpause() (at Assets/OverworldPauseMenu.cs:47) UnityEngine.EventSystems.EventSystem:Update() (at /Applications/Unity/Hub/Editor/2019.3.15f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)

The code for the PauseMenu:

public class OverworldPauseMenu : MonoBehaviour
{
    public GameObject pauseScreen;
    public GameObject TouchUICanvas;
    public string mainMenu;
    public bool isPaused;
    ControlsSetup controls;
    public void Awake()
    {
        controls = new ControlsSetup();

        controls.SwitchPro.ButtonStart.performed += ctx => PauseUnpause();
    }
    void Start()
    {

    }
    void Update()
    {

    }
    public void PauseUnpause()
    {
        if (isPaused)
        {
            isPaused = false;
            TouchUICanvas.SetActive(true);
            pauseScreen.SetActive(false);

            Time.timeScale = 1f;
        }
        else
        {
            isPaused = true;
            TouchUICanvas.SetActive(false);
            pauseScreen.SetActive(true);

            Time.timeScale = 0f;
        }
    }
    public void MainMenu()
    {
        SceneManager.LoadScene(mainMenu);
        Time.timeScale = 1f;
    }
    void OnEnable()
    {
        controls.SwitchPro.Enable();
    }
    void OnDisable()
    {
        controls.SwitchPro.Disable();
    }
}

See relevant images below.
StartButton:

Controls Setup:

Console ERROR:

6jygbczu

6jygbczu1#

我“解决”了这个问题,延迟一帧按钮游戏对象禁用。有点hacky,但至少为我工作。

相关问题