๋ฌธ์ ๊ฐ ๋์๋ ์ฝ๋
//----------------------์ฝ๋๋ถ-----------------------------------
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; public class KeyBindingSetting : MonoBehaviour { public List<InputActionReference> Actions; private InputActionRebindingExtensions.RebindingOperation rebindOperation; void RebindCompleted(KeySettingSection section) { rebindOperation.Dispose(); rebindOperation = null; section.UpdateText(); } public void StartInteractiveRebind(KeySettingSection section) { rebindOperation = Actions[section.RebindActionIndex].action .PerformInteractiveRebinding() .WithControlsExcluding("<Mouse>/position") .WithControlsExcluding("<Mouse>/delta") .WithControlsExcluding("<Gamepad>/Start") .WithControlsExcluding("<Keyboard>/escape") .OnMatchWaitForAnother(0.1f) .OnComplete(operation => RebindCompleted(section)); rebindOperation.Start(); } }๋ณธ์ธ์ ์ธํ ์์คํ ์์ ์ถ๊ฐ์ ์ผ๋ก ๊ฑด๋ค ์ผ์ด ์๊ธธ ๊ฒฝ์ฐ, ๊ทธ ๋ด์ฉ์ด ๋ฐ๋ก ๋ฐ์๋ ์ ์๋๋ก ์์ ์์ ์ง์ ์ก์ ๋ ํผ๋ฐ์ค๋ฅผ ๋์ด๋ค๊ฐ ๋ฐ์์ค๋ ๋ฐฉ์์ผ๋ก ๋ฆฌ๋ฐ์ธ๋ฉ ๊ตฌ์กฐ๋ฅผ ๊ตฌํํ๊ณ ์ ํ์
๊ทธ๋ฐ๋ฐ ์ด ๋ฐฉ์์ผ๋ก ํ๋, ๋ถ๋ช ํ ํค ๋ฆฌ๋ฐ์ธ๋๊ฐ ๋ก๊ทธ์์๋ ๋๋ฌ๋๊ณ , section.UpdateText(); ํจ์ ๊ตฌ๋ ์์๋ ๋ณ๊ฒฝ๋ ๋ฐ์ธ๋ฉ ์ธํ ์ผ๋ก ๋๋ฌ๋๋๋ฐ๋ ๋ถ๊ตฌํ๊ณ ๋ฐ์ธ๋ฉ์ด ์ ์๋๋ ํ์์ด ๋ฐ์ํ์์
์ด๊ฑธ ๊ณ ์น๊ธฐ ์ํด ์ด๋๊ฐ ๋ฌธ์ ์ง ํ๊ณ ์ฐพ์๋ดค์๋๋ฐ, ์ผ๋จ๊ฒฐ์ ๋ค๋ฅธ ํ๋ก์ ํธ ์ฝ๋์ ๋์กฐํ๋ค๋ณด๋ ์ด๋๊ฐ ๋ฌธ์ ์๋์ง ์๊ฒ ๋์์
//์ดํ ๋ด์ฉ์ ์ถ๋ก ์ ๋ด๋ฆฐ ๊ฒฐ๋ก ์
์ด ๋ฐฉ์๋๋ก ํ ๊ฒฝ์ฐ ์์ ์ด ๋ด๊ณ ์๋ ๋ ํผ๋ฐ์ค์ ์ ๋ณด๋ ๊ฐฑ์ ์ด ๋๋๋ฐ, ํ๋ ์ด์ด ์์ง์์ ์ ์ดํ๋ ๋ถ๋ถ์์๋ ๊ฐฑ์ ์ด ์ ๋์ด์ ๋ณ๋๋ก ๊ฐฑ์ ์ ์ง์ ํด ์ค์ผ ํ๋ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ ๊ฑฐ์์
์ด ๋ถ๋ถ์ ์์ ํ๊ณ ์ ๋ค์๊ณผ ๊ฐ์ด ์ฝ๋๋ฅผ ์์ ํ๊ฒ ๋์์
//--------------------์ฝ๋๋ถ------------------------------
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; public class KeyBindingSetting : MonoBehaviour { public InputActionAsset IAA; public List<InputActionReference> Actions; private InputActionRebindingExtensions.RebindingOperation rebindOperation; void RebindCompleted(KeySettingSection section) { rebindOperation.Dispose(); rebindOperation = null; GameController.GetPlayer.GetComponent<PlayerInput>().actions = IAA; section.UpdateText(); } public void StartInteractiveRebind(KeySettingSection section) { rebindOperation = Actions[section.RebindActionIndex].action .PerformInteractiveRebinding() .WithControlsExcluding("<Mouse>/position") .WithControlsExcluding("<Mouse>/delta") .WithControlsExcluding("<Gamepad>/Start") .WithControlsExcluding("<Keyboard>/escape") .OnMatchWaitForAnother(0.1f) .OnComplete(operation => RebindCompleted(section)); rebindOperation.Start(); } }๋ณ๊ฒฝ๋ ์ก์ ๋ ํผ๋ฐ์ค๋ฅผ ๋ด๊ณ ์๋ ์ธํ ์ก์ ์์ ์ ๋๊ณ ์ค๊ณ , ๊ทธ๊ฒ์ ์ฑ๊ธํค์ผ๋ก ์ถ์ ์ค์ธ ํ๋ ์ด์ด์ ํ๋ ์ด์ด ์ก์ ์ปดํฌ๋ํธ์ ๋ฃ์ด์ ์ง์ ๊ฐฑ์ ๋ ๊ฐ์ ๋ฃ์ด์ฃผ๋ ๋ฐฉ์์ผ๋ก ๋๋ ธ์
์์ฝ๋ก๋กฌ ๋ฐ๊พธ๋ ์ด์ ์ผ ๋ฆฌ๋ฐ์ธ๋ฉ ๋ ํค ์ ๋ ฅ์ ๋ฐ์๋ค์ด๊ฒ ๋๋๋ผ
์์ ๋๋ฐฉ์ผ๋ก ๋ฐฉ์๋ง ์์๋ธ๊ฑฐ๋ผ ๋นํจ์จ์ ์ธ ๋ถ๋ถ์ด ๋จ์ ์๊ธด ํ๋ฐ, ์ด ๋ถ๋ถ์ ๊ฐ์ ์์ ๋ค์ด๊ฐ๋ฉด ๋๋ ๋ฌธ์ ์ด๊ธฐ๋ ํ๊ณ , ์ฐ์ ์ ์ด๋ ๋ฌธ์ ์ ์ด ์ด๋์ธ์ง๋ ์ฐพ์๋ด์ ๋๋ฆ ๋ณด๋์ ๋๊ผ์
๊ตฌํ ์์ฒด๊ฐ ์ข ๊น๋ค๋กญ๊ธฐ๋ ํ์ด๋, ๋๋ถ์ ์ข์ ๊ณต๋ถ๊ฐ ๋์์
ํน์๋ผ๋ ๋น์ทํ๊ฒ ํด๋งค๋ ์ธ๋ถ์ด๋ค ์์๊น๋ด ํ์ฐฎ์ ๊ธ ๋จ๊ธฐ๊ณ ๊ฐ...
//ps. ํน์ ์ข ๋ ๊ฐ์ฉ๋ ๋ฐฉ์๊ฐ์๊ฑฐ ์๊ณ ๊ณ์๋ฉด ๋๊ธ๋ก ๋จ๊ฒจ์ฃผ์๋ฉด ๋งค์ฐ ๊ฐ์ฌํ๊ฒ์ด๋๋ค...
//์์ (2022.08.27.15.05)
๋ฆฌ๋ฐ์ธ๋ ๊ณผ์ ์งํ์ค์ ํด๋น ์ก์ ์ ์ผ๋จ Disable()๋ก ๋ฐ๊พธ๊ณ ์, ์ ํ ํ Enable() ๋ก ํด์ฃผ์ ์ผ ๋ฌธ์ ๊ฐ ์์๊น๋๋ค...
์ฝ๊ฐ ์ด๋ฐ ๋๋์ผ๋ก
Input Action ๊ทธ๋ฅ ๊ฐ๋ค์จ์ ์ ๋ชฐ๋๋๋ฐ ํค ๋ฐ์ธ๋ฉ์ xml ๊ฐ์๋ฐ๋ค ํด๋๋๊ฑด๊ฐ๋ณด๋ค
์ข์ ๊ธ์ด์์ค. ํ์ง๋ง ํค์ค์ ๊ธฐ๋ฅ์ ๋ฃ์ง ์์์ผ๊ฒ ๋ค๋ ์๊ฐ์ด ๋ค์ด๋ฒ๋ ธ์ด์ค.