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

Bug Physical Camera settings from script

Discussion in 'Scripting' started by IMTactica, Aug 16, 2023.

  1. IMTactica

    IMTactica

    Joined:
    Oct 16, 2019
    Posts:
    19
    Good day,

    I'm having a hard time enabling Physical Camera option in Camera component.
    It works flawlessly from the Editor, but the
    Code (CSharp):
    1. usePhysicalProperties = true
    does nothing.
    Is there a way to toggle Physical Camera from the script or force update upon Camera after setting given boolean?
    Is that a bug or this behavior is intended?

    Thanks in advance!
     
  2. faUnity

    faUnity

    Joined:
    Aug 7, 2023
    Posts:
    14
  3. IMTactica

    IMTactica

    Joined:
    Oct 16, 2019
    Posts:
    19
    Camera component is added to the GO instantiated in the scene.
    What I'm trying to achieve is exactly this:
    Code (CSharp):
    1.  Camera cam = gameObject.GetComponent<Camera>();
    2. cam.usePhysicalProperties = true;
    ̶B̶u̶t̶ ̶i̶f̶ ̶y̶o̶u̶ ̶t̶r̶y̶ ̶i̶t̶ ̶i̶n̶ ̶e̶m̶p̶t̶y̶ ̶p̶r̶o̶j̶e̶c̶t̶ ̶w̶i̶t̶h̶ ̶j̶u̶s̶t̶ ̶o̶n̶e̶ ̶G̶O̶ ̶w̶i̶t̶h̶ ̶a̶c̶t̶i̶v̶e̶ ̶c̶a̶m̶e̶r̶a̶ ̶a̶n̶d̶ ̶t̶h̶i̶s̶ ̶c̶o̶d̶e̶ ̶s̶n̶i̶p̶p̶e̶t̶ ̶i̶n̶ ̶M̶o̶n̶o̶B̶e̶h̶a̶v̶i̶o̶r̶,̶ ̶u̶s̶e̶P̶h̶y̶s̶i̶c̶a̶l̶P̶r̶o̶p̶e̶r̶t̶i̶e̶s̶ ̶=̶ ̶t̶r̶u̶e̶ ̶w̶o̶n̶'̶t̶ ̶t̶r̶i̶g̶g̶e̶r̶ ̶t̶h̶e̶ ̶c̶h̶a̶n̶g̶e̶ ̶f̶o̶r̶ ̶t̶h̶e̶ ̶c̶a̶m̶e̶r̶a̶.̶
    In the new project it works as intended, I guess it some other local interference.
     
    Last edited: Aug 17, 2023