using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour
{
public Vector2 jumpForce = new Vector2(0, 300);
public GameObject Egg;
public Transform eggpoint;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyUp("space") || Input.GetMouseButtonDown(0))
{
GetComponent<Rigidbody2D>().velocity = Vector2.zero;
GetComponent<Rigidbody2D>().AddForce(jumpForce);
}
if(Input.GetKeyDown(KeyCode.Return))
{
Instantiate(Egg, eggpoint.position, eggpoint.rotation);
}
So as you guys can see in the separate box how I am instantiating my egg droping code. And I am achieving this by pressing the return or enter button on the keyboard, what I want to ask is how can I use a button to do it rather than the enter. So I have placed a UI button on my game screen but as I am absolute beginner I can't figure out how to connect the button and the function please guide me to the right tutorial.