22 Temmuz 2016 Cuma

GETBUTTON VE GETKEY

Bu kavramlar kullanıcının klavye etkileşimini ifade eder.Şimdi daha akından bakalım

- GetButton = Belirlenen bir tuşa basılı kaldığı sürece true değer döner.

- GetButtonDown = Belirlenen bir tuşa ilk basıldığında 1 kez true değer döner.

- GetButtonUp = Belirlenen ve basılan tuş bırakıldıında 1 seferlik true değer döner

GetKey bundan farklı değildir sadece getButton da Key ile ulaşılan bir yerin ismini direkt olarak kullanırsınız. Örneğin "jump" derseniz space olduğunu anlar ama getkey de space e basılacağını söylemelisiniz.  .

GetKey Kullanımı

  void Update ()
    {
        bool down = Input.GetButtonDown("Jump");
        bool held = Input.GetButton("Jump");
        bool up = Input.GetButtonUp("Jump");
        
        if(down)
        {
            graphic.texture = downgfx;
        }
        else if(held)
        {
            graphic.texture = heldgfx;
        }
        else if(up)
        {
            graphic.texture = upgfx;
        }
        else
        {
            graphic.texture = standard;
        }
    
        guiText.text = " " + down + "\n " + held + "\n " + up;
    }

GetButton Kullanımı

 void Update ()
    {
        bool down = Input.GetKeyDown(KeyCode.Space);
        bool held = Input.GetKey(KeyCode.Space);
        bool up = Input.GetKeyUp(KeyCode.Space);
        
        if(down)
        {
            graphic.texture = downgfx;
        }
        else if(held)
        {
            graphic.texture = heldgfx;
        }
        else if(up)
        {
            graphic.texture = upgfx;
        }
        else
        {
            graphic.texture = standard; 
        }
        
        guiText.text = " " + down + "\n " + held + "\n " + up;
    }

Hiç yorum yok:

Yorum Gönder