Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class AutoScaler : MonoBehaviour
  4. {
  5. [SerializeField]
  6. private float defaultHeight = 1.8f;
  7. [SerializeField]
  8. private Camera camera;
  9.  
  10. private void Resize()
  11. {
  12. float headHeight = camera.transform.localPosition.y;
  13. float scale = defaultHeight / headHeight;
  14. transform.localScale = Vector3.one * scale;
  15. }
  16.  
  17. void OnEnable()
  18. {
  19. Resize();
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement