Skip to content

Instantly share code, notes, and snippets.

@kaiware007
Last active September 16, 2018 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaiware007/b5c949caa358c88a1ed64b67da224ec6 to your computer and use it in GitHub Desktop.
Save kaiware007/b5c949caa358c88a1ed64b67da224ec6 to your computer and use it in GitHub Desktop.
Orthographicカメラの大きさいっぱいにTransformを拡縮するスクリプト(Unity3D)
using UnityEngine;
public class ScreenAdjustTransform : MonoBehaviour {
public Camera targetCamera = null;
void AdjustScreen()
{
float height = targetCamera.orthographicSize * 2;
float width = height * targetCamera.aspect;
transform.localScale = new Vector3(width, height, 1);
}
// Use this for initialization
void Start () {
AdjustScreen();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment