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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Finding prefab-camera which is child of main camera

Discussion in '2D' started by jjuyiopt, Jun 17, 2020.

  1. jjuyiopt

    jjuyiopt

    Joined:
    Sep 2, 2019
    Posts:
    2
    Hi i`m using unity for some college assignments

    I get "Easy Fog of War" asset in unity asset store and apply it on my own unity project. It said that put a prefab camera which makes fow as the child of main camera.

    my own unity project is a slightly modified version of "Minimalist Puzzle" asset. At the start of the game(at void Awake(){}), Gamemanager Scripts adjusts main camera`s orthographicsize to fit in the game scene. And it doesn`t move until that stage ends.

    after applying FoW, I can`t find the way to adjust the orthographicsize of prefab camera. If I can`t find it, I can still build it and run it but those 2 camera have different orthographicsize. So it looks weird.

    I want to find the prefab camera which is child of main camera inside the Gamemanager. Then, I can adjust it`s orthographicsize.

    this is my hierarchy
    upload_2020-6-17_13-2-55.png

    And this is part of my script when adjusting the orthogrpahicsize of camera

    private void Awake()
    {
    inst = this;
    Camera cam = Camera.main;
    //Camera cam2 = transform.Find("FowCamera");
    //Set Screen Size
    float orth;
    if (Screen.height < Screen.width)
    {
    //Horizontal
    Ui[0].GetComponent<GridLayoutGroup>().constraintCount = 4;
    Vector2[] point = Collider.points;
    point[0] = new Vector3(100, 175);
    point[1] = new Vector3(-100, 175);
    Collider.points = point;
    Collider.transform.eulerAngles = new Vector3(0, 0, -90);
    orth = Collider.bounds.size.y * Screen.height / Screen.width;
    Debug.Log(orth); Debug.Log(cam);
    }
    else
    {
    orth = Collider.bounds.size.x * Screen.height / Screen.width * 0.5f;
    }
    Camera.main.orthographicSize = orth;
    Debug.Log(Camera.main.orthographicSize);
    //cam2.orthographicSize = orth;
     
  2. jjuyiopt

    jjuyiopt

    Joined:
    Sep 2, 2019
    Posts:
    2
    Additionally, I can`t use transform.getchild() cuz it returns unityengine.transform but I need unityengine.camera to adjust orthographicsize