Having issues determining a way to use buttons in a script.

Hi, first, I do know that you can use On Click() and add in functions and various things, but to me that seems very complicated and just not programmer friendly… atleast the way I’m looking at it.

So I’ve tried a couple of things but I cant seem to find the right function for what I’m trying to do.

Basically I want something I can use to trigger an if statement, when I press a button down. Currently I’ve tried OnPointerDown, but it seems that it is an event and not a Bool value, and unfortunately I do not understand the event system. In anycase if anyone could help in giving me an idea of how I can do this that would be awesome!

Also worth noting button is not noticed as a component in declaration unless declared as seen below, not sure if thats a bug… IE “Button Quit;”
I imagine the code would look something like this.

using UnityEngine;
using System.Collections;

public class quit : Monobehaviour{

public UnityEngine.UI.Button Quit;
    
void start(){   
Quit = GetComponent<UnityEngine.UI.Button>();
            }
void update(){
if (quit.MAGICFUNCTIONRELATEDTOCLICKING == true){
Debug.Log ("Application was exited");
Application.Quit();
}
}
}

Rather than guessing, I recommend you follow some tutorials about how to use the UI system: Unity Connect

I ended up writing a function to handle it using the event system, though I definitely was not asking for information on that. I’d still like another way to do it by using the button to flip a bool value for ifstatements. In anycase, I’m using sendmessage to call functions instead…