unity3D 中,要实时更改GUI.Box 的宽度应该怎么做?设定了一个参数,参数在UPDate里是变化的,宽度没变
展开全部
using UnityEngine;
using System.Collections;
public class BoxWidth : MonoBehaviour
{
private float _width = 100.0f;
// Use this for initialization
IEnumerator Start()
{
while (true)
{
yield return new WaitForSeconds(1);
_width = 100*Random.Range(1.0f, 2.0f);
}
}
// Update is called once per frame
void Update()
{
//_width = 100 * Random.Range(1.0f, 2.0f);//很快
}
void OnGUI()
{
GUI.Box(new Rect(100, 100, _width, 100), "Box Box Box");
}
}
using System.Collections;
public class BoxWidth : MonoBehaviour
{
private float _width = 100.0f;
// Use this for initialization
IEnumerator Start()
{
while (true)
{
yield return new WaitForSeconds(1);
_width = 100*Random.Range(1.0f, 2.0f);
}
}
// Update is called once per frame
void Update()
{
//_width = 100 * Random.Range(1.0f, 2.0f);//很快
}
void OnGUI()
{
GUI.Box(new Rect(100, 100, _width, 100), "Box Box Box");
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询