Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用Unity'指定对象的旋转值;s更新功能_C#_Unity3d - Fatal编程技术网

C# 如何使用Unity'指定对象的旋转值;s更新功能

C# 如何使用Unity'指定对象的旋转值;s更新功能,c#,unity3d,C#,Unity3d,我想指定统一的对象旋转值 我不想旋转对象 我编写了以下代码 using System.Collections; using System.Collections.Generic; using UnityEngine; public class test_rotate : MonoBehaviour { int test_x = 10; // Use this for initialization void Start () {

我想指定统一的对象旋转值

我不想旋转对象

我编写了以下代码

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

    public class test_rotate : MonoBehaviour {

        int test_x = 10;

        // Use this for initialization
        void Start () {

        }

        // Update is called once per frame
        void Update () {
            this.transform.Rotate(test_x, 0, 0);
        }
    }
然后对象开始旋转

这不是我想要的

我只想将对象的旋转值设置为(10,0,0)

我还尝试了以下代码:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class test_rotate : MonoBehaviour {

    int test_x = 10;

    // Use this for initialization
    void Start () {
        this.transform.Rotate(test_x, 0, 0);
    }

    // Update is called once per frame
    void Update () {
    }
}
然后它按预期工作,但是我想用Update函数而不是Start函数来完成这项工作

我该怎么办?

transform.Rotate()
每次调用对象时都会旋转它


您要做的是设置变换的旋转:
transform.rotation=Quaternion.Euler(test_x,0,0)

如果只想设置一次,为什么要在更新(每帧运行)中执行此操作?