2,537
社区成员
发帖
与我相关
我的任务
分享
private bool _instate=false;
private float _timer=0f;
[SerializeField] float speed=1.5f;
public void StartMove()
{
_timer=0f;
StartCoroutine(MOVEINCOROUTINE());
}
public void StopMove()
{
_instate=false;
}
IEnumerator MOVEINCOROUTINE()
{
_instate = true;
while(_instate)
{
this.transform.position=new Vector3(-10f+_timer*speed,1f,10f);
_timer+=Time.deltaTime;
yield return null;
}
this.transform.localPosition=new Vector3 (0f,-5f,10f);
}
[SerializeField]CubeMoveAgent _cube;
void OnGUI()
{
if (GUILayout.Button ("TimeScale=4", GUILayout.Width (150.0f), GUILayout.Height (75.0f)))
{
Time.timeScale = 4f;
}
if (GUI.Button (new Rect(Screen.width-150.0f,10f,150f,75f),"Start Move"))//, GUILayout.Width (150.0f), GUILayout.Height (75.0f)))
{
_cube.StartMove();
}
if (GUI.Button (new Rect(Screen.width-150.0f,90f,150f,75f),"Stop Move"))
{
_cube.StopMove();
}
}