Guest User

Untitled

a guest
Mar 23rd, 2020
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class inputmouse : MonoBehaviour {
  6.  
  7.     string teks1,teks2,teks3,teks4;
  8.     int jmlScrol;
  9.     float delta;
  10.     // Use this for initialization
  11.     void Start () {
  12.         jmlScrol=0;
  13.     }
  14.    
  15.     // Update is called once per frame
  16.     void Update () {
  17.         if(Input.GetKey(KeyCode.Mouse0)){
  18.             teks1 = "Mouse: Klik Kiri";
  19.  
  20.         }else if(Input.GetMouseButton(1)){
  21.             teks1 = "Mouse: Klik Kanan";
  22.         }
  23.         teks2 = "Position: "+ Input.mousePosition.ToString();
  24.  
  25.         if(Input.mouseScrollDelta.y > 0){
  26.             delta = Input.mouseScrollDelta.y;
  27.             jmlScrol++;
  28.         }else if(Input.mouseScrollDelta.y < 0){
  29.             delta = Input.mouseScrollDelta.y;
  30.             jmlScrol--;
  31.         }
  32.         teks3 = "Scroll: "+delta.ToString();
  33.         teks4 = "Jumlah Scroll: "+jmlScrol.ToString();
  34.     }
  35.     void OnGUI(){
  36.         GUILayout.BeginArea(new Rect(10,15,400,200));
  37.         GUILayout.Label(teks1);
  38.         GUILayout.Label(teks2);
  39.         GUILayout.Label(teks3);
  40.         GUILayout.Label(teks4);
  41.         GUILayout.EndArea();
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment