Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
シーンビューの位置カメラの位置を元にカメラを動かす
using UnityEngine;
using System.Collections;
using UnityEditor;
using System;
public class FollowSceneCamera : EditorWindow {
[MenuItem("Window/Camera/FollowSceneCamera")]
static void Init()
{
var window = EditorWindow.FindObjectOfType<FollowSceneCamera>();
if( window != null )
window.Close();
window = EditorWindow.CreateInstance<FollowSceneCamera>();
window.Show();
}
public Camera sceneCamera
{
get{ eturn SceneView.lastActiveSceneView.camera; }
}
void OnGUI()
{
foreach( var camera in GameObject.FindObjectsOfType<Camera>())
{
GUILayout.BeginHorizontal();
if( GUILayout.Button(camera.name) )
{
Undo.RecordObject(camera.transform, "camera");
camera.transform.position = sceneCamera.transform.position ;
camera.transform.rotation = sceneCamera.transform.rotation;
}
if( GUILayout.Button("F", GUILayout.Width(30)) )
{
Selection.activeGameObject = camera.gameObject;
}
GUILayout.EndHorizontal();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.