Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity check if key pressed

if (Input.GetKeyDown(KeyCode.KEY))
Comment

if button is pressed unity

    using UnityEngine;
    using System.Collections;
    using UnityEngine.EventSystems;
     
    public class MyButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler {
     
    public bool buttonPressed;
     
    public void OnPointerDown(PointerEventData eventData){
         buttonPressed = true;
    }
     
    public void OnPointerUp(PointerEventData eventData){
        buttonPressed = false;
    }
    }
Comment

how to check if button is pressed unity

// Buttons work by adding listeners to the event of their onclick. 
// These listeners can be persistent or runtime listeners. 
// Persistent listeners are assigned in the editor and the runtime 
// listeners are assigned in code at runtime. 
// Here is how you would assign a new listener in code.

public class Controller : MonoBehaviour
{
    [SerializeField] private Button btn = null;

    private void Awake()
    {
        // adding a delegate with no parameters
        btn.onClick.AddListener(NoParamaterOnclick);
           
        // adding a delegate with parameters
        btn.onClick.AddListener(delegate{ParameterOnClick("Button was pressed!");});
    }
    
    private void NoParamaterOnclick()
    {
        Debug.Log("Button clicked with no parameters");
    }
    
    private void ParameterOnClick(string test)
    {
        Debug.Log(test);
    }
}
Comment

how to check to see if the keyboard buttons are pressed in unity

if(Input.GetKey()
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# int division to double 
Csharp :: show datatable c# 
Csharp :: .net return result encoding as utf8 
Csharp :: c# convert xml to list string 
Csharp :: c# return two values 
Csharp :: how to show a first item in a combobox in c# winforms 
Csharp :: how to display a form when a button click c# windows form 
Csharp :: hashtable in c# 
Csharp :: maximum sum subarray c# 
Csharp :: c# HttpResponseMessage postResponse = client.PostAsync 
Csharp :: c# if else 
Csharp :: quaternion to euler 
Csharp :: c# nunit test case 
Csharp :: How can I get my stripe customer ID? 
Csharp :: string length f# 
Csharp :: how to use var in c# 
Csharp :: string vs string c# 
Csharp :: cefsharp print 
Csharp :: how to make a chunk loader in c# 
Csharp :: index list c# 
Csharp :: wpf button to return to last window 
Csharp :: infinit range loop c# 
Csharp :: how to make a beep in c# 
Csharp :: c# XmlElement from string 
Csharp :: how to extract data from a document using c# 
Csharp :: mvc input number rounding 
Csharp :: firefoxoptions setpreference to trust certificates 
Csharp :: hur delar man upp en e post på string c# 
Csharp :: how to instantiate particle system with a particular rotation 
Csharp :: c# is file closed 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =