GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
jack.wynne
/
HoloLens_Scripts_and_Docs
Browse code
Create SetFocusOnUpdate
master
1 parent
21b2c00
commit
f780e599598b96e142d5fb2bd12c1fd27c1302b6
Jack Wynne
authored
on 22 Jun 2017
Patch
Showing
1 changed file
SetFocusOnUpdate
Ignore Space
Show notes
View
SetFocusOnUpdate
0 → 100644
using UnityEngine; using UnityEngine.VR.WSA; public class SetFocusOnUpdate : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update() { if (IsTargetVisible()) { HolographicSettings.SetFocusPointForFrame(gameObject.transform.position, -Camera.main.transform.forward); } } private bool IsTargetVisible() { // This will return true if the target's mesh is within the Main Camera's view frustums. Vector3 targetViewportPosition = Camera.main.WorldToViewportPoint(gameObject.transform.position); return (targetViewportPosition.x > 0.0 && targetViewportPosition.x < 1 && targetViewportPosition.y > 0.0 && targetViewportPosition.y < 1 && targetViewportPosition.z > 0); } }
Show line notes below