//按钮有提示 点击后可以移动gameobject的坐标
using UnityEngine;
using System.Collections;
public class HHHHHHHH : MonoBehaviour {
public GUISkin GUISkin;
public GameObject gameobject; //要移动的物体
public string [] Appellations=new string[3]{"aaa","bbb","ccc"}; //名称
public string [] AppellationTooltips =new string[3]{"AAA","BBB","CCC"}; //提示
public Vector3 [] Target_Points=new Vector3[3]{new Vector3(0F,0F,0F),new Vector3(1F,0F,0F),new Vector3(0F,2F,0F)};
public ArrayList StrName=new ArrayList();
public int jiajia=0;
public bool Istoggle;
public Rect AppellationRect;
public int index=-0;
void Start () {
AppellationRect=new Rect(150F,0f,500F,70F);
}
void Update () {
}
void OnGUI () {
GUI.skin=GUISkin;
if(!Istoggle)
{
GUILayout.BeginArea(AppellationRect);
GUILayout.BeginHorizontal();
for(int i=0;i<Appellations.Length;i++)
{
if(GUILayout.Button(new GUIContent(Appellations[i],AppellationTooltips[i]),GUILayout.Width(80)))
{
MovePosition(Target_Points[i]);
}
if(GUI.tooltip==AppellationTooltips[i])
{
index=i;
}
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Space(20+index*80);
GUILayout.Button(GUI.tooltip,GUILayout.Width(120));
GUILayout.EndHorizontal();
GUILayout.EndArea ();
}
if(Istoggle)
{
GUILayout.BeginArea(AppellationRect);
GUILayout.BeginHorizontal();
for(int i=0;i<Appellations.Length;i++)
{
if(GUILayout.Button(new GUIContent(Appellations[i],AppellationTooltips[i]),GUILayout.Width(80)))
{
MovePosition(Target_Points[i]);
}
}
GUILayout.EndHorizontal();
GUILayout.Button(GUI.tooltip);
GUILayout.EndArea ();
}
if(GUILayout.Button("Istoggle"))
{
Istoggle=!Istoggle;
}
if(GUILayout.Button("AddButton"))
{
jiajia++;
StrName.Add("xiao"+jiajia);
}
for(int i=0;i<StrName.Count;i++)
{
if(GUILayout.Button((string)StrName[i]))
{
}
}
}
void OnMouseEnter ()
{
}
void MovePosition(Vector3 V3)
{
gameobject.transform.position=V3;
}
}