Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class AutoScaler : MonoBehaviour
- {
- [SerializeField]
- private float defaultHeight = 1.8f;
- [SerializeField]
- private Camera camera;
- private void Resize()
- {
- float headHeight = camera.transform.localPosition.y;
- float scale = defaultHeight / headHeight;
- transform.localScale = Vector3.one * scale;
- }
- void OnEnable()
- {
- Resize();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement