naverz / zepeto-script-sample

38 stars 7 forks source link

unity input system 접근 방법 #45

Closed MetaVersusUniverse closed 3 years ago

MetaVersusUniverse commented 3 years ago

if(Input.GetMouseButtonDown(0)) 화면 터치 입력을 받고 싶어 유니티 엔진의 input을 import하고 위의 코드를 사용했습니다.

코드 상의 에러는 없으나 play mode 진입 시 아래와 같은 에러가 발생합니다. 유니티 엔진의 input에 접근할 수 있는 방법이 궁금합니다.

// System.Exception: file://D:\Users\csim4\Desktop\DistanceBtn\Assets\Scripts\ButtonDistanceCheck.js:52: Error: c# exception:You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.,stack: at (wrapper managed-to-native) UnityEngine.Input.GetMouseButtonDown(int) at UnityEngine.InputLegacyModule.Generated.UnityEngine_Input_Wrap+<>c.b__7_0 (System.Int32 button) [0x00000] in :0 at ZEPETO.Script.WrapperContextExtensions.StaticWrap[TReturn,T0] (ZEPETO.Script.WrapperContext context, ZEPETO.Script.StaticFunc`2[TReturn,T0] binding, System.Boolean hasParams, ZEPETO.Script.WrapperType type) [0x00045] in <8cf0081224034bf184d73190721f76f6>:0 )

Error: c# exception:You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.,stack: at (wrapper managed-to-native) UnityEngine.Input.GetMouseButtonDown(int) at UnityEngine.InputLegacyModule.Generated.UnityEngine_Input_Wrap+<>c.b__7_0 (System.Int32 button) [0x00000] in :0 at ZEPETO.Script.WrapperContextExtensions.StaticWrap[TReturn,T0] (ZEPETO.Script.WrapperContext context, ZEPETO.Script.StaticFunc`2[TReturn,T0] binding, System.Boolean hasParams, ZEPETO.Script.WrapperType type) [0x00045] in <8cf0081224034bf184d73190721f76f6>:0 )

at ButtonDistanceCheck.TouchRayCastCheck (file://D:\Users\csim4\Desktop\DistanceBtn\Assets\Scripts\ButtonDistanceCheck.js:52:33)
at ButtonDistanceCheck.Update (file://D:\Users\csim4\Desktop\DistanceBtn\Assets\Scripts\ButtonDistanceCheck.js:12:14)
at file://D:\Users\csim4\Desktop\DistanceBtn\builtin\proxy.js:8:70

at Puerts.GenericDelegate.Action[T1] (T1 p1) [0x00055] in <8cf0081224034bf184d73190721f76f6>:0 at ZEPETO.Script.ZepetoScriptInstance.InvokeEvent (ZEPETO.Script.ZepetoScriptInstance+Events event, System.Object param) [0x00025] in <8cf0081224034bf184d73190721f76f6>:0 at ZEPETO.Script.ZepetoScriptBehaviourComponent.InvokeEvent (ZEPETO.Script.ZepetoScriptInstance+Events events, System.Object param) [0x00011] in <8cf0081224034bf184d73190721f76f6>:0 UnityEngine.Debug:LogError (object) ZEPETO.Script.ZepetoScriptBehaviourComponent:InvokeEvent (ZEPETO.Script.ZepetoScriptInstance/Events,object) ZEPETO.Script.ZepetoScriptContext:Invoke (ZEPETO.Script.ZepetoScriptInstance/Events) ZEPETO.Script.ZepetoScriptContext:OnUpdate () ZEPETO.Script.ZepetoScriptContextComponent:Update ()

moondory77-naverz commented 3 years ago

안녕하세요. 현재 작업하고 계신 유니티 프로젝트의 InputSystem이 New로 설정되어있어 그렇습니다. (Legacy Input API를 사용하려 할 때 에러발생) Edit >> Player >> Configuration >> Active Input Handling을 Both로 변경한 다음 사용해주세요.