Camera Culling

If you want to disable the Unit UI while the action camera is active you can also do something like this:

    [SerializeField] GameObject actionCameraGameObject;
    
    [SerializeField] LayerMask normalCameraCullingMask;
    [SerializeField] LayerMask actionCameraCullingMask;

    void Start() {
        BaseAction.OnAnyActionStarted += OnAnyActionStarted;
        BaseAction.OnAnyActionCompleted += OnAnyActionCompleted;
        HideActionCamera();
    }

    void ShowActionCamera() {
        Camera.main.cullingMask = actionCameraCullingMask;
        actionCameraGameObject.SetActive(true);
    }

    void HideActionCamera() {
        Camera.main.cullingMask = normalCameraCullingMask;
        actionCameraGameObject.SetActive(false);
    }

Then set the normal camera mask to ‘everything’ and disable the ‘ui’ layer on the action camera mask.

5 Likes

That’s a nice tip!

CONFIGURE an object in the scene “Canvas” - Render mode - Screen space Camera
otherwise it doesn’t work

I know this is an older post, but I was having a tough time figuring out how to hide the UnitUI. So, thank you for this! <3

What exactly did you mean by this? Hiding the UI worked just fine for me without any extra setup.

I added another little bit to allow it to be configured. Another option one could do is to have the shooting action have some control over it (or other extras), so one might be able to tune it so the action camera is just applied on a critical hit, or on a killing shot…

Privacy & Terms