Last active
April 23, 2023 16:53
-
-
Save tsubaki/aff143051d2942d1319f to your computer and use it in GitHub Desktop.
シーンビューの位置カメラの位置を元にカメラを動かす
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 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