我需要创建新按钮,允许在下面的代码中克隆按钮,请分享一些想法,代码,链接,脚本。我会很高兴得到任何帮助。提前谢谢!
using UnityEngine;
using System.Collections;
public class hibye: MonoBehaviour
{
public string slectedItem = "fd";
private bool editing = false;
private void OnGUI()
{
if ( GUILayout.Button(slectedItem))
{
editing = true;
}
if (editing)
{
string[] sig = {"Banana","Apple","Orange"};
for (int x = 0; x < sig.Length ; x++)
{
if (GUILayout.Button(sig[x]))
{
slectedItem = sig[x];
editing = false;
}
}
}
}
}
答案 0 :(得分:0)
如果您想要点击Apple bannana等新按钮?
试试这个:
for (int x = 0; x < sig.Length ; x++)
{
GUI.Button(new rect(0,0,0,0),sig[x]));
}
用于可点击的可执行按钮
for (int x = 0; x < sig.Length ; x++)
{
if(GUI.Button(new rect(0,0,0,0),sig[x]))
{
}
}
希望这是有用的,因为它有点晚了^^