Created
May 23, 2018 15:37
-
-
Save progrium/3921c4a1a90ef889a993a402b0a09d8d 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 System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEditor; | |
[ExecuteInEditMode] | |
public class FollowSceneCamera : MonoBehaviour { | |
private Vector3 lastPosition; | |
private Quaternion lastRotation; | |
void OnEnable() { | |
lastPosition = transform.position; | |
lastRotation = transform.rotation; | |
} | |
void OnDisable() { | |
transform.position = lastPosition; | |
transform.rotation = lastRotation; | |
} | |
void OnRenderObject () { | |
transform.position = SceneView.currentDrawingSceneView.camera.transform.position; | |
transform.rotation = SceneView.currentDrawingSceneView.camera.transform.rotation; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment