Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Display 2D Unity camera frame

Discussion in '2D' started by R0tmayer, Mar 13, 2021.

  1. R0tmayer

    R0tmayer

    Joined:
    Mar 13, 2021
    Posts:
    12
    When the camera is not selected, there is no frame. When selected, there is a frame. Gizmo is on. I just created a new project, didn't touch anything else
     
  2. R0tmayer

    R0tmayer

    Joined:
    Mar 13, 2021
    Posts:
    12
    The problem was solved by imposing a script on the camera (one guy helped me)


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class CameraScript : MonoBehaviour
    6. {
    7.     // Start is called before the first frame update
    8.     void OnDrawGizmos()
    9.     {
    10.         float verticalHeightSeen = GetComponent<Camera>().orthographicSize * 2.0f;
    11.         float verticalWidthSeen = verticalHeightSeen * GetComponent<Camera>().aspect;
    12.  
    13.  
    14.         Gizmos.color = Color.gray;
    15.         Gizmos.DrawWireCube(transform.position, new Vector3(verticalWidthSeen,verticalHeightSeen,0));
    16.     }
    17. }
    18.