GetMouseButtonUp









How do I use Get Mouse Button Up
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: InputToEvent.cs Copy
32     void Update()
33     {
34         if( DetectPointedAtGameObject )
35         {
36             goPointedAt = RaycastObject( Input.mousePosition );
37         }
38
39         if( Input.touchCount > 0 )
40         {
41             Touch touch = Input.GetTouch( 0 );
42             this.currentPos = touch.position;
43
44             if( touch.phase == TouchPhase.Began )
45             {
46                 Press( touch.position );
47             }
48             else if( touch.phase == TouchPhase.Ended )
49             {
50                 Release( touch.position );
51             }
52
53             return;
54         }
55
56         currentPos = Input.mousePosition;
57         if( Input.GetMouseButtonDown( 0 ) )
58         {
59             Press( Input.mousePosition );
60         }
61         if( Input.GetMouseButtonUp( 0 ) )
62         {
63             Release( Input.mousePosition );
64         }
65
66         if( Input.GetMouseButtonDown( 1 ) )
67         {
68             pressedPosition = Input.mousePosition;
69             lastGo = RaycastObject( pressedPosition );
70             if( lastGo != null )
71             {
72                 lastGo.SendMessage( "OnPressRight", SendMessageOptions.DontRequireReceiver );
73             }
74         }
75     }
File name: InputManager.cs Copy
39  void Update() {
40   mouseAxis.x = Input.GetAxis("Mouse X");
41   mouseAxis.y = Input.GetAxis("Mouse Y");
42
43   if (InputEvent == null) return;
44
45   if (!GameManager.Instance.IsReady) return;
46
47   HighlightTile();
48
49   if (Input.GetMouseButtonUp(0)) {
50    if (GameManager.Instance.GameState.IsWaiting) {
51     UnHighlightTile();
52     InputEvent(InputActionType.GRAB_PIECE);
53    } else if (GameManager.Instance.GameState.IsHolding) {
54     InputEvent(InputActionType.PLACE_PIECE);
55    }
56   }
57
58   if (Input.GetMouseButtonUp(1)) {
59    if (GameManager.Instance.GameState.IsHolding) {
60     InputEvent(InputActionType.CANCEL_PIECE);
61    }
62   }
63
64   if (Input.GetAxis("Mouse ScrollWheel") > 0) {
65    InputEvent(InputActionType.ZOOM_IN);
66   }
67
68   if (Input.GetAxis("Mouse ScrollWheel") < 0) {
69    InputEvent(InputActionType.ZOOM_OUT);
70   }
71
72   if (Input.GetMouseButtonDown(2)) {
73    InputEvent(InputActionType.ROTATE);
74   } else if (Input.GetMouseButtonUp(2)) {
75    InputEvent(InputActionType.STOP_ROTATE);
76   }
77  }
File name: PlayerMoveScript.cs Copy
50  void Update () {
51
52   grounded = Physics2D.OverlapCircle(groundCheck.position, groundChecked, isGround);
53
54   if(transform.position.x > speedCount) {
55    speedCount += speedIncrease;
56    speedIncrease = speedIncrease * speedMultiplier;
57    moveSpeed = moveSpeed * speedMultiplier;
58   }
59
60   rigidbody.velocity = new Vector2 (moveSpeed, rigidbody.velocity.y);
61
62   if(Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0)) {
63
64    if(grounded) {
65     rigidbody.velocity = new Vector2 (rigidbody.velocity.x, jumpForce);
66     anim.SetTrigger ("Jump");
67     stopJumping = false;
68    }
69   }
70
71   if((Input.GetKey(KeyCode.Space) || Input.GetMouseButton(0)) && !stopJumping) {
72    if(jumpTimeCounter > 0) {
73     rigidbody.velocity = new Vector2 (rigidbody.velocity.x, jumpForce);
74     jumpTimeCounter -= Time.deltaTime;
75    }
76   }
77
78   if(Input.GetKeyUp (KeyCode.Space) || Input.GetMouseButtonUp(0)) {
79    jumpTimeCounter = 0;
80    stopJumping = true;
81   }
82
83   if(grounded) {
84    jumpTimeCounter = jumpTime;
85   }
86
87
88   scoreCount += pointsPerSeconds = Time.deltaTime;
89
90   if(scoreCount > highScoreCount) {
91    highScoreCount = scoreCount;
92
93   }
94   scoreText.text = "Score: " + Mathf.Round(scoreCount);
95
96  }
File name: GameManager.cs Copy
20     private bool InputTaken()
21     {
22         return Input.touchCount > 0 || Input.GetMouseButtonUp(0);
23     }
File name: GameScreen.cs Copy
379         public void LateUpdate()
380         {
381             if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Space))
382             {
383                 if (InputController.Name == InputNames.GAMESCREEN)
384                 {
385                     if (InputController.IsScreen)
386                     {
387                         if(Time.timeScale != 0)
388                             animals.getAnimal(0).GetComponent().Jump();
389                         //createBuiTien(-1.2f, 1f);
390                     }
391                 }
392             }
393             else if (Input.GetMouseButtonUp(0))
394             {
395                 InputController.IsScreen = true;
396             }
397             if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Backspace))
398             {
399                 if (!isPrepare)
400                 {
401                     if (dialog != null && dialog.activeSelf && InputController.Name == InputNames.DIALOG)
402                     {
403                         dialog.GetComponent().hideDialog();
404                         pauseLayer.SetActive(true);
405                     }else if (InputController.Name == InputNames.GAMESCREEN)
406                     {
407                         pauseGame();
408                         dialog.GetComponent().showDialog();
409                         pauseLayer.SetActive(false);
410                     }
411                     else if (pauseLayer.activeSelf)
412                     {
413                         resumeGame();
414                     }
415                 }
416             }
417             if (isPrepare)
418             {
419                 isPrepare = false;
420
421                 buttonSkills.setFonts(shopFont);
422                 prepareGame();
423             }
424         }
File name: TouchText.cs Copy
33         public void LateUpdate()
34         {
35             if (InputController.Enabled && InputController.Name == InputNames.MAINMENU)
36             {
37                 if (Input.GetButtonDown("Fire1") && InputController.IsScreen)
38                 {
39                     SceneManager.LoadScene("MapScreen");
40                 }
41                 else if (Input.GetMouseButtonUp(0))
42                 {
43                     InputController.IsScreen = true;
44                 }
45             }
46         }

GetMouseButtonUp 160 lượt xem

Gõ tìm kiếm nhanh...