小编Ima*_*oon的帖子

有没有办法从按钮单击启动方法而不使用统一的Update()函数

下面是我的C#脚本.我在项目中添加了一个带有On Click事件的按钮,并调用了Rotate()方法.但由于某种原因它不起作用

using System.Threading;
using UnityEngine;

public class Orbit : MonoBehaviour {

    public GameObject sun;
    public float speed;

    // Use this for initialization
    void Start () {

    }

    public void Update()
    {
        Rotate();
    }

    public void Rotate()
    {
        transform.RotateAround(sun.transform.position, Vector3.up, speed * 
        Time.deltaTime);
    }
}
Run Code Online (Sandbox Code Playgroud)

我在调用Rotate()方法时注释了Update()方法.我还为脚本创建了一个游戏对象.

c# unity-game-engine vuforia

2
推荐指数
1
解决办法
109
查看次数

标签 统计

c# ×1

unity-game-engine ×1

vuforia ×1