I have a GUI Texture and the following script is attach to it.
using UnityEngine;
using System.Collections;
public class moveUP : MonoBehaviour {
public float moveSpeed=3f;
public GameObject player;
void OnGUI() {
if (Input.GetMouseButton(0))
player.transform.Translate(Vector3.up * moveSpeed * Time.deltaTime);
}
It works not only when I click the GUI Texture, but also whereever I click on the screen.
How can I fix this?
Or if you have any other script for moving a player with GUI Texture feel free to share it.