using UnityEngine;
using System.Collections;
public class Test : MonoBehaviour
{
public GUISkin skin;
public string txt;
private bool menuState = false;
private Vector2 oldCursonPos;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void FixedUpdate()
{
}
void OnGUI()
{
GUI.skin = skin;
txt = GUI.TextField(new Rect(100, 100, 80, 20), txt, 4);
if (Input.GetMouseButtonDown(0))
{
RightMenu();
//menuState = false;
}
if (Input.GetMouseButtonDown(1))
{
menuState = true;
oldCursonPos = Input.mousePosition;
}
RightMenu();
}
void RightMenu()
{
if (menuState)
{
if (GUI.Button(new Rect(oldCursonPos.x, Screen.height - oldCursonPos.y, 100, 20), "复制"))
{
Debug.Log("复制");
menuState = false;
}
if (GUI.Button(new Rect(oldCursonPos.x, Screen.height - oldCursonPos.y + 20, 100, 20), "粘贴"))
{
Debug.Log("粘贴");
menuState = false;
}
}
}
}