Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active April 23, 2023 16:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/aff143051d2942d1319f to your computer and use it in GitHub Desktop.
Save tsubaki/aff143051d2942d1319f to your computer and use it in GitHub Desktop.
シーンビューの位置カメラの位置を元にカメラを動かす
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