Created
September 27, 2014 02:14
-
-
Save sapphire-al2o3/545f3f9947f21f92d97e to your computer and use it in GitHub Desktop.
Unityでカメラのインスペクタに注視点で角度設定するボタンをつけるエディタ拡張のスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
[CustomEditor(typeof(Camera))] | |
public class LookAtCameraEditor : Editor | |
{ | |
Vector3 value; | |
public override void OnInspectorGUI() | |
{ | |
DrawDefaultInspector(); | |
EditorGUILayout.BeginHorizontal(); | |
value = EditorGUILayout.Vector3Field("target", value); | |
if (GUILayout.Button("Look", GUILayout.MaxWidth(60))) | |
{ | |
Camera c = target as Camera; | |
Undo.RecordObject(c, "Camera LookAt"); | |
c.transform.rotation = Quaternion.LookRotation(value - c.transform.position); | |
EditorUtility.SetDirty(target); | |
} | |
EditorGUILayout.EndHorizontal(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment