コード例 #1
0
 void LateUpdate()
 {
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         CanvasControl.CloseWindowFocus();
         Debug.Log("Closing Window");
     }
     if (Input.GetKeyDown(KeyCode.LeftControl))
     {
         CanvasControl.CloseWindowFocus();
         Debug.Log("Closing Window");
     }
     if (Input.GetKeyDown(KeyCode.Space))
     {
         Debug.Log("Selecting item " + selectedItem);
         CanvasControl.OpenWindow(menuItem[selectedItem].name);
     }
     if (Input.GetKeyDown(KeyCode.W))
     {
         selectedItem = SelectUp(selectedItem);
         CanvasControl.SetSelection(selectedItem);
     }
     else if (Input.GetKeyDown(KeyCode.S))
     {
         selectedItem = SelectDown(selectedItem);
         CanvasControl.SetSelection(selectedItem);
     }
     if (Input.GetKeyDown(KeyCode.D))
     {
         selectedItem = SelectRight(selectedItem);
     }
     if (Input.GetKeyDown(KeyCode.A))
     {
         selectedItem = SelectLeft(selectedItem);
     }
     if (Input.GetKey(KeyCode.W))
     {
         menuInputTimer += Time.deltaTime;
         if (menuInputTimer >= 1 && menuInputTimer == 1)
         {
             selectedItem = SelectUp(selectedItem);
             CanvasControl.SetSelection(selectedItem);
         }
         else if (menuInputTimer > 1.2)
         {
             selectedItem = SelectUp(selectedItem);
             CanvasControl.SetSelection(selectedItem);
             menuInputTimer = 1;
         }
     }
     if (Input.GetKey(KeyCode.S))
     {
         menuInputTimer += Time.deltaTime;
         if (menuInputTimer >= 1 && menuInputTimer == 1)
         {
             selectedItem = SelectDown(selectedItem);
             CanvasControl.SetSelection(selectedItem);
         }
         else if (menuInputTimer > 1.2)
         {
             selectedItem = SelectDown(selectedItem);
             CanvasControl.SetSelection(selectedItem);
             menuInputTimer = 1;
         }
     }
     if (Input.GetKeyUp(KeyCode.W))
     {
         menuInputTimer = 0;
     }
     if (Input.GetKeyUp(KeyCode.S))
     {
         menuInputTimer = 0;
     }
 }