Game Development Reference
In-Depth Information
The Size field controls how world units map to pixels on screen
You can set the Size field directly in the editor, but this would only work if your
game resolution is constant and never changes. If the user can resize the game
window or change the game resolution, then you would need to update the
camera size in script, as shown in the following code sample 5-8:
01 //-------------------------------------------------------
02 using UnityEngine;
03 using System.Collections;
04 //-------------------------------------------------------
05 [RequireComponent(typeof(Camera))]
06 //-------------------------------------------------------
07 public class OrthoCam : MonoBehaviour
08 {
09 //private reference to camera component
10 private Camera Cam = null;
11
12 //Reference to Pixels to World Units Scale
13 public float PixelsToWorldUnits = 200f;
14 //-------------------------------------------------------
15 // Use this for initialization
16 void Awake ()
17 {
18 //Get camera reference
19 Cam = GetComponent<Camera>();
20 }
21 //-------------------------------------------------------
22 // Update is called once per frame
 
Search WWH ::




Custom Search