Friday 13 October 2017

Unity 2D Camera Bounds

Watch Video Tutorial On Youtube


using UnityEngine;
using System.Collections;
 
public class CameraBounds : MonoBehaviour
{
 
    Vector3 screensize;
    public GameObject Right;
    public GameObject left;
    // Use this for initialization
 
 
    void Start()
    {
   screensize = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0));
 
    }
    // Update is called once per frame
    void Update()
    {
  screensize = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0));
  Right.transform.position = new Vector2(screensize.+ 0.65f0);
  left.transform.position = new Vector2((screensize.- 0.65f- 
   Camera.main.orthographicSize * Camera.main.aspect * 2f0);
    }
}

No comments:

Post a Comment