Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class EirikGUI : MonoBehaviour {
- public float offset;
- public GUISkin skin;
- public Texture mainTex;
- public Texture downTex;
- public bool pushed;
- private Rect rect = new Rect(0,0,50,100);
- // Use this for initialization
- void Update () {
- //offset = 300 + (Mathf.Sin(Time.time * 3) * 30);
- rect = new Rect(5 + offset,0, 50, 100);
- }
- // Update is called once per frame
- void OnGUI () {
- GUI.skin = skin;
- GUILayout.BeginArea(rect);
- GUILayout.Label("LOL");
- if(GUILayout.Button("", (GUIStyle)"MyImgButton", GUILayout.Width(50), GUILayout.Height(50))) {
- Debug.Log("POOSHED");
- }
- GUILayout.EndArea();
- GUI.DrawTexture(rect, pushed ? downTex : mainTex);
- if(rect.Contains(Input.mousePosition)) {
- if(Input.GetMouseButtonDown(0)) {
- pushed = true;
- } else if(Input.GetMouseButtonUp() && pressed) {
- //do stuff
- pushed = false;
- }
- } else if(Input.GetMouseButtonUp(0)){
- pushed = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement