Created
January 25, 2016 19:09
-
-
Save jonbro/b591700056fed8abe60f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| if(Tools.viewTool == ViewTool.FPS){ | |
| // move the camera into the nearest sector, then set it to the correct player height | |
| // oooh boy, this is some silly shit ya gotta do to set the position properly :D | |
| // via https://github.com/MattRix/UnityDecompiled/blob/master/UnityEditor/UnityEditor/SceneViewMotion.cs#L136 | |
| float d = 0; | |
| Vector3 lastPosition = SceneView.lastActiveSceneView.camera.transform.position; | |
| Transform cameraTransform = SceneView.lastActiveSceneView.camera.transform; | |
| Sector currentSector = sectorEditor.map.sectors[0]; | |
| foreach(Sector s in sectorEditor.map.sectors){ | |
| if(s.ContainsPoint(new Vector2(cameraTransform.position.x, cameraTransform.position.z))){ | |
| currentSector = s; | |
| } | |
| } | |
| d = (SceneView.lastActiveSceneView.pivot - cameraTransform.position).magnitude; | |
| cameraTransform.position = new Vector3(lastPosition.x, currentSector.floorHeight+1.2f, lastPosition.z); | |
| SceneView.lastActiveSceneView.pivot = cameraTransform.position + cameraTransform.forward * d; | |
| SceneView.lastActiveSceneView.Repaint(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment