以下の内容はhttps://baba-s.hatenablog.com/entry/2019/11/27/120000より取得しました。


【Unity】Transform の Rotation を Inspector における入力と同様に設定する方法

概要

localEulerAngles を使用する方法

using UnityEditor;
using UnityEngine;

public static class Example
{
    [MenuItem( "CONTEXT/Transform/Example" )]
    private static void Hoge( MenuCommand command )
    {
        var t = command.context as Transform;
        t.localEulerAngles = new Vector3( 270, 540, 810 );
    }
}

f:id:baba_s:20191125141642g:plain

localEulerAngles を使用して回転角を設定する場合、数値が自動で補正される

TransformUtils.SetInspectorRotation

using UnityEditor;
using UnityEngine;

public static class Example
{
    [MenuItem( "CONTEXT/Transform/Example" )]
    private static void Hoge( MenuCommand command )
    {
        var t = command.context as Transform;
        TransformUtils.SetInspectorRotation( t, new Vector3( 270, 540, 810 ) );
    }
}

f:id:baba_s:20191125141709g:plain

TransformUtils.SetInspectorRotationを使用する場合、数値をそのまま設定できる




以上の内容はhttps://baba-s.hatenablog.com/entry/2019/11/27/120000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14