コード例 #1
0
 private bool ProcessElementAssignmentConflictCheck(ControlRemappingDemo1.ElementAssignmentChange entry)
 {
     if (ReInput.players.GetPlayer(entry.playerId) == null)
     {
         return true;
     }
     if (entry.controllerMap == null)
     {
         return true;
     }
     if (entry.state == ControlRemappingDemo1.QueueEntry.State.Canceled)
     {
         return true;
     }
     if (entry.state == ControlRemappingDemo1.QueueEntry.State.Confirmed)
     {
         entry.changeType = ControlRemappingDemo1.ElementAssignmentChangeType.Add;
         if (entry.response == ControlRemappingDemo1.UserResponse.Confirm)
         {
             ReInput.controllers.conflictChecking.RemoveElementAssignmentConflicts(entry.ToElementAssignmentConflictCheck());
             entry.ReplaceOrCreateActionElementMap();
         }
         else
         {
             if (entry.response != ControlRemappingDemo1.UserResponse.Custom1)
             {
                 throw new NotImplementedException();
             }
             entry.ReplaceOrCreateActionElementMap();
         }
         return true;
     }
     bool flag = false;
     foreach (ElementAssignmentConflictInfo current in ReInput.controllers.conflictChecking.ElementAssignmentConflicts(entry.ToElementAssignmentConflictCheck()))
     {
         if (!current.isUserAssignable)
         {
             flag = true;
             break;
         }
     }
     if (flag)
     {
         string message = entry.elementName + " is already in use and is protected from reassignment. You cannot remove the protected assignment, but you can still assign the action to this element. If you do so, the element will trigger multiple actions when activated.";
         this.dialog.StartModal(entry.id, ControlRemappingDemo1.DialogHelper.DialogType.AssignElement, new ControlRemappingDemo1.WindowProperties
         {
             title = "Assignment Conflict",
             message = message,
             rect = this.GetScreenCenteredRect(250f, 200f),
             windowDrawDelegate = new Action<string, string>(this.DrawElementAssignmentProtectedConflictWindow)
         }, new Action<int, ControlRemappingDemo1.UserResponse>(this.DialogResultCallback));
     }
     else
     {
         string message2 = entry.elementName + " is already in use. You may replace the other conflicting assignments, add this assignment anyway which will leave multiple actions assigned to this element, or cancel this assignment.";
         this.dialog.StartModal(entry.id, ControlRemappingDemo1.DialogHelper.DialogType.AssignElement, new ControlRemappingDemo1.WindowProperties
         {
             title = "Assignment Conflict",
             message = message2,
             rect = this.GetScreenCenteredRect(250f, 200f),
             windowDrawDelegate = new Action<string, string>(this.DrawElementAssignmentNormalConflictWindow)
         }, new Action<int, ControlRemappingDemo1.UserResponse>(this.DialogResultCallback));
     }
     return false;
 }
コード例 #2
0
 private bool ProcessAddOrReplaceElementAssignment(ControlRemappingDemo1.ElementAssignmentChange entry)
 {
     if (ReInput.players.GetPlayer(entry.playerId) == null)
     {
         return true;
     }
     if (entry.controllerMap == null)
     {
         return true;
     }
     if (entry.state == ControlRemappingDemo1.QueueEntry.State.Canceled)
     {
         return true;
     }
     if (entry.state != ControlRemappingDemo1.QueueEntry.State.Confirmed)
     {
         string text;
         if (entry.controllerType == ControllerType.Keyboard)
         {
             if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXWebPlayer)
             {
                 text = "Press any key to assign it to this action. You may also use the modifier keys Command, Control, Alt, and Shift. If you wish to assign a modifier key ifselt this action, press and hold the key for 1 second.";
             }
             else
             {
                 text = "Press any key to assign it to this action. You may also use the modifier keys Control, Alt, and Shift. If you wish to assign a modifier key itself to this action, press and hold the key for 1 second.";
             }
             if (Application.isEditor)
             {
                 text += "\n\nNOTE: Some modifier key combinations will not work in the Unity Editor, but they will work in a game build.";
             }
         }
         else if (entry.controllerType == ControllerType.Mouse)
         {
             text = "Press any mouse button or axis to assign it to this action.\n\nTo assign mouse movement axes, move the mouse quickly in the direction you want mapped to the action. Slow movements will be ignored.";
         }
         else
         {
             text = "Press any button or axis to assign it to this action.";
         }
         this.dialog.StartModal(entry.id, ControlRemappingDemo1.DialogHelper.DialogType.AssignElement, new ControlRemappingDemo1.WindowProperties
         {
             title = "Assign",
             message = text,
             rect = this.GetScreenCenteredRect(250f, 200f),
             windowDrawDelegate = new Action<string, string>(this.DrawElementAssignmentWindow)
         }, new Action<int, ControlRemappingDemo1.UserResponse>(this.DialogResultCallback), 5f);
         return false;
     }
     if (Event.current.type != EventType.Layout)
     {
         return false;
     }
     if (!ReInput.controllers.conflictChecking.DoesElementAssignmentConflict(entry.ToElementAssignmentConflictCheck()))
     {
         entry.ReplaceOrCreateActionElementMap();
     }
     else
     {
         ControlRemappingDemo1.ElementAssignmentChange elementAssignmentChange = new ControlRemappingDemo1.ElementAssignmentChange(entry);
         elementAssignmentChange.changeType = ControlRemappingDemo1.ElementAssignmentChangeType.ConflictCheck;
         this.actionQueue.Enqueue(elementAssignmentChange);
     }
     return true;
 }