Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 풀 리퀘스트는 게임 내에서 키보드/마우스 및 게임패드 입력에 대한 키 리바인딩 기능을 완벽하게 구현합니다. 사용자는 이제 원하는 대로 키 바인딩을 변경하고, 이를 저장 및 불러올 수 있으며, 필요에 따라 초기화할 수도 있습니다. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
| public void OnClickRebindJump() => rebindingManager.StartRebinding(jumpAction); | ||
| public void OnClickRebindUISelect() => rebindingManager.StartRebinding(uiSelectAction); | ||
| public void OnClickRebindGrab() => rebindingManager.StartRebinding(grabAction, "Keyboard, Mouse"); | ||
| public void OnClickRebindPush() => rebindingManager.StartRebinding(pushAction); |
There was a problem hiding this comment.
RebindingManager.StartRebinding 메소드의 기본 controlScheme 값이 "Keyboard&Mouse"로 잘못 설정되어 있어, controlScheme을 명시하지 않은 호출들은 리바인딩에 실패할 수 있습니다. 모든 호출에 "Keyboard, Mouse"를 명시적으로 전달하도록 수정하는 것을 권장합니다.
public void OnClickRebindJump() => rebindingManager.StartRebinding(jumpAction, "Keyboard, Mouse");
public void OnClickRebindUISelect() => rebindingManager.StartRebinding(uiSelectAction, "Keyboard, Mouse");
public void OnClickRebindGrab() => rebindingManager.StartRebinding(grabAction, "Keyboard, Mouse");
public void OnClickRebindPush() => rebindingManager.StartRebinding(pushAction, "Keyboard, Mouse");| "UIControll" | ||
| }; | ||
|
|
||
| public void StartRebinding(InputActionReference actionReference, string controlScheme = "Keyboard&Mouse") |
There was a problem hiding this comment.
| { | ||
| [SerializeField] private RebindingManager rebindingManager; | ||
|
|
||
| [Header("�����ε� ������ �Ǹ� ���")] |
| Debug.Log("1"); | ||
|
|
||
| InputAction action = actionReference.action; | ||
|
|
||
| if (_lockedActions.Contains(action.name)) return; | ||
|
|
||
| Debug.Log("2"); | ||
|
|
||
| int bindingIndex = action.GetBindingIndex( | ||
| InputBinding.MaskByGroup(controlScheme) | ||
| ); | ||
|
|
||
| if (bindingIndex == -1) | ||
| { | ||
| Debug.LogWarning($"[{action.name}] {controlScheme} ���ε� ����"); | ||
| return; | ||
| } | ||
|
|
||
| action.Disable(); | ||
|
|
||
| _rebindOperation = action | ||
| .PerformInteractiveRebinding(bindingIndex) | ||
| .WithControlsExcluding("<Mouse>/position") | ||
| .WithControlsExcluding("<Mouse>/delta") | ||
| .WithControlsExcluding("<Mouse>/scroll") | ||
| .WithCancelingThrough("<Keyboard>/escape") | ||
| .WithoutGeneralizingPathOfSelectedControl() | ||
| .OnMatchWaitForAnother(0.2f) | ||
| .OnComplete(operation => | ||
| { | ||
| Debug.Log(3); |
| Debug.LogWarning($"[{action.name}] {controlScheme} ���ε� ����"); | ||
| return; | ||
| } | ||
|
|
||
| action.Disable(); | ||
|
|
||
| _rebindOperation = action | ||
| .PerformInteractiveRebinding(bindingIndex) | ||
| .WithControlsExcluding("<Mouse>/position") | ||
| .WithControlsExcluding("<Mouse>/delta") | ||
| .WithControlsExcluding("<Mouse>/scroll") | ||
| .WithCancelingThrough("<Keyboard>/escape") | ||
| .WithoutGeneralizingPathOfSelectedControl() | ||
| .OnMatchWaitForAnother(0.2f) | ||
| .OnComplete(operation => | ||
| { | ||
| Debug.Log(3); | ||
| action.Enable(); | ||
| _rebindOperation?.Dispose(); | ||
| _rebindOperation = null; | ||
| SaveBindings(); | ||
| Debug.Log($"[{action.name}] [{controlScheme}] �����ε� �Ϸ�: {action.bindings[bindingIndex].effectivePath}"); | ||
| }) | ||
| .OnCancel(operation => | ||
| { | ||
| action.Enable(); | ||
| _rebindOperation?.Dispose(); | ||
| _rebindOperation = null; | ||
| Debug.Log($"[{action.name}] �����ε� ���"); |
There was a problem hiding this comment.
| public void ResetBinding(InputActionReference actionReference, int bindingIndex = 0) | ||
| { | ||
| if (actionReference == null) return; | ||
|
|
||
| InputAction action = actionReference.action; | ||
|
|
||
| if (_lockedActions.Contains(action.name)) return; | ||
|
|
||
| action.RemoveBindingOverride(bindingIndex); | ||
| } |
There was a problem hiding this comment.
ResetBinding 메소드가 bindingIndex를 인자로 받지만, 기본값 0을 사용하면 의도치 않은 바인딩을 초기화할 수 있습니다. StartRebinding처럼 controlScheme을 사용하여 초기화할 바인딩을 명확하게 찾는 것이 더 안전합니다.
public void ResetBinding(InputActionReference actionReference, string controlScheme = "Keyboard, Mouse")
{
if (actionReference == null) return;
InputAction action = actionReference.action;
if (_lockedActions.Contains(action.name)) return;
int bindingIndex = action.GetBindingIndex(InputBinding.MaskByGroup(controlScheme));
if (bindingIndex != -1)
{
action.RemoveBindingOverride(bindingIndex);
}
}| private void SaveBindings() | ||
| { | ||
| string json = inputActions.SaveBindingOverridesAsJson(); | ||
| PlayerPrefs.SetString("InputBindings", json); | ||
| PlayerPrefs.Save(); | ||
| } | ||
|
|
||
| public void LoadBindings() | ||
| { | ||
| if (PlayerPrefs.HasKey("InputBindings")) | ||
| inputActions.LoadBindingOverridesFromJson(PlayerPrefs.GetString("InputBindings")); | ||
| } |
| public void LoadBindings() | ||
| { | ||
| if (PlayerPrefs.HasKey("InputBindings")) | ||
| inputActions.LoadBindingOverridesFromJson(PlayerPrefs.GetString("InputBindings")); | ||
| } |
사용방법: 인풋 UI에 버튼 입력 추가,
조작방식이 키보드일 경우
StartRebinding(인풋액션, 조작법)에서
조작법에 해당하는 위치에 "Keyboard, Mouse"
게임패드일 경우에는 "Gamepad" 입력, 바인딩 잘됩니당
제작한 내용
리바인딩, 세이브, 리셋, 로딩