Skip to content

Instantly share code, notes, and snippets.

@unity3dcollege
Created August 18, 2017 03:02
Show Gist options
  • Save unity3dcollege/eb0936bdea13d4325f4b0f783f40ae18 to your computer and use it in GitHub Desktop.
Save unity3dcollege/eb0936bdea13d4325f4b0f783f40ae18 to your computer and use it in GitHub Desktop.
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();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment