Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

input.getbutton unity

ButtonInput
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class ButtonInput : MonoBehaviour
{
    public Image graphic;
    public Sprite standard;
    public Sprite downgfx;
    public Sprite upgfx;
    public Sprite heldgfx;
    public Text boolDisplay1;
    public Text boolDisplay2;
    public Text boolDisplay3;

    void Start()
    {
        graphic.sprite = standard;    
    }

    void Update()
    {
        bool down = Input.GetButtonDown("Jump");
        bool held = Input.GetButton("Jump");
        bool up = Input.GetButtonUp("Jump");

        if(down)
        {
            graphic.sprite = downgfx;
        }
        else if (held)
        {
            graphic.sprite = heldgfx;
        }
        else if (up)
        {
            graphic.sprite = upgfx;
        }
        else
        {
            graphic.sprite = standard;
        }

        boolDisplay1.text = " " + down;
        boolDisplay2.text = " " + held;
        boolDisplay3.text = " " + held;
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: select a whole row out of a 2d array C# 
Csharp :: concatenate two lists in c# 
Csharp :: factorial of any number 
Csharp :: linq contains 
Csharp :: c# timer single tick 
Csharp :: c# reflection get property value array 
Csharp :: mysql restore backup from multiple files 
Csharp :: unity navmeshagent set destination 
Csharp :: list add value position c# 
Csharp :: c# do while or 
Csharp :: how to get params our of url c# VB 
Csharp :: ef core many to many fluent api 
Csharp :: convert list of string to dictionary 
Csharp :: create stripe subscription pay_immediately 
Csharp :: change object position 
Csharp :: ascii code c# char 
Csharp :: get xml from url 
Csharp :: using statement c# 
Csharp :: out c# 
Csharp :: c# async task constructor 
Csharp :: calculate string length vs pixels c# 
Csharp :: How to remove an element from Array List in C#? 
Csharp :: c sharp xml prettier 
Csharp :: c# odp.net close session 
Csharp :: linq query to fetch parent child data from same table in c# 
Csharp :: how many zeros in quinnonagintillion 
Csharp :: how to list all registered users asp net 
Csharp :: Unity how get Attributes of a gameObject 
Csharp :: angular === vs == 
Csharp :: upload file add more size webconfig in asp.net mvc 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =