├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md └── SceneViewCopier.cs /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | /[Bb]uilds/ 6 | /Assets/AssetStoreTools* 7 | 8 | # Visual Studio 2015 cache directory 9 | /.vs/ 10 | 11 | # Autogenerated VS/MD/Consulo solution and project files 12 | ExportedObj/ 13 | .consulo/ 14 | *.csproj 15 | *.unityproj 16 | *.sln 17 | *.suo 18 | *.tmp 19 | *.user 20 | *.userprefs 21 | *.pidb 22 | *.booproj 23 | *.svd 24 | *.pdb 25 | 26 | # Unity3D generated meta files 27 | *.pidb.meta 28 | 29 | # Unity3D Generated File On Crash Reports 30 | sysinfo.txt 31 | 32 | # Builds 33 | *.apk 34 | *.unitypackage 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Robert Kossessa 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unity Scene View Copier 2 | Makes positioning Cameras in [Unity](https://unity3d.com/) much easier. Copies Scene View properties to Camera components. 3 | 4 | ## Features 5 | - Enables following Scene View for fast and easy camera positioning 6 | - Allows separate copying of position, rotation and camera settings 7 | - Fully supports Undo and Redo 8 | - Can edit multiple objects 9 | - Small editor below Camera component editor: 10 | 11 | ![sceneviewcopier_inspector](https://user-images.githubusercontent.com/34353377/36560205-6c242146-1810-11e8-8e1b-cd049a59e193.jpg) 12 | 13 | ![sceneviewcopier_screenshot](https://user-images.githubusercontent.com/34353377/36560476-1ec99042-1811-11e8-92e5-0250c8134476.jpg) 14 | 15 | ## How to use 16 | Simply add [SceneViewCopier.cs](SceneViewCopier.cs) to your project ([Editor folder](https://docs.unity3d.com/Manual/SpecialFolders.html)). A box containing the controls will appear below every Camera component editor. 17 | 18 | ## License 19 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. 20 | 21 | [![forthebadge](https://forthebadge.com/images/badges/makes-people-smile.svg)](https://forthebadge.com) 22 | -------------------------------------------------------------------------------- /SceneViewCopier.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | [CustomEditor(typeof(Camera)), CanEditMultipleObjects] 5 | public class SceneViewCopier : Editor 6 | { 7 | private bool follow = false; 8 | 9 | public override void OnInspectorGUI() 10 | { 11 | DrawDefaultInspector(); 12 | 13 | EditorGUILayout.Space(); 14 | 15 | EditorGUILayout.BeginVertical(GUI.skin.box); 16 | 17 | EditorGUILayout.LabelField(new GUIContent("Copy")); 18 | 19 | EditorGUILayout.BeginHorizontal(); 20 | 21 | if (GUILayout.Button(new GUIContent("Position"))) 22 | { 23 | SceneView view = SceneView.lastActiveSceneView; 24 | if (view != null) 25 | { 26 | for (int i = 0; i < targets.Length; i++) 27 | { 28 | Camera temp = (Camera)targets[i]; 29 | Undo.RecordObject(temp.transform, "Copy Scene View Position"); 30 | temp.transform.position = view.camera.transform.position; 31 | } 32 | } 33 | } 34 | 35 | if (GUILayout.Button(new GUIContent("Rotation"))) 36 | { 37 | SceneView view = SceneView.lastActiveSceneView; 38 | if (view != null) 39 | { 40 | for (int i = 0; i < targets.Length; i++) 41 | { 42 | Camera temp = (Camera)targets[i]; 43 | Undo.RecordObject(temp.transform, "Copy Scene View Rotation"); 44 | temp.transform.rotation = view.camera.transform.rotation; 45 | } 46 | } 47 | } 48 | 49 | if (GUILayout.Button(new GUIContent("Settings"))) 50 | { 51 | SceneView view = SceneView.lastActiveSceneView; 52 | if (view != null) 53 | { 54 | for (int i = 0; i < targets.Length; i++) 55 | { 56 | Camera temp = (Camera)targets[i]; 57 | Undo.RecordObject(temp, "Copy Scene View Settings"); 58 | temp.fieldOfView = view.camera.fieldOfView; 59 | temp.orthographic = view.camera.orthographic; 60 | temp.orthographicSize = view.camera.orthographicSize; 61 | temp.nearClipPlane = view.camera.nearClipPlane; 62 | temp.farClipPlane = view.camera.farClipPlane; 63 | } 64 | } 65 | } 66 | 67 | EditorGUILayout.EndHorizontal(); 68 | 69 | EditorGUI.BeginChangeCheck(); 70 | follow = EditorGUILayout.Toggle(new GUIContent("Follow"), follow); 71 | if (EditorGUI.EndChangeCheck()) 72 | { 73 | Tools.hidden = follow; 74 | SceneView.RepaintAll(); 75 | } 76 | 77 | EditorGUILayout.EndVertical(); 78 | } 79 | 80 | private void OnSceneGUI() 81 | { 82 | if (follow) 83 | { 84 | SceneView view = SceneView.lastActiveSceneView; 85 | if (view != null) 86 | { 87 | Camera temp = (Camera)target; 88 | Undo.RecordObject(temp.transform, "Follow Scene View"); 89 | temp.transform.position = view.camera.transform.position; 90 | temp.transform.rotation = view.camera.transform.rotation; 91 | } 92 | } 93 | } 94 | 95 | private void OnDisable() 96 | { 97 | Tools.hidden = false; 98 | } 99 | } 100 | --------------------------------------------------------------------------------