HeliosDoubleSix

CopySceneView

Sep 1st, 2014
434
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEditor;
  4.  
  5. [ExecuteInEditMode,InitializeOnLoad]
  6. public class CopySceneView : MonoBehaviour {
  7.  
  8.     void Start () {
  9.         EditorApplication.update -= Update;
  10.         EditorApplication.update += Update;
  11.     }
  12.    
  13.     public Camera sceneCamera = null;
  14.    
  15.     void Update () {
  16.         if( sceneCamera  == null && SceneView.lastActiveSceneView != null && SceneView.lastActiveSceneView.camera != null ){
  17.             sceneCamera = SceneView.lastActiveSceneView.camera;
  18.         }      
  19.         if(sceneCamera!=null){
  20.             transform.position = sceneCamera.transform.position;
  21.             transform.rotation = sceneCamera.transform.rotation;
  22.         }
  23.     }
  24.  
  25.     void OnDisable() {
  26.         EditorApplication.update -= Update;
  27.     }
  28. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×