How to SetActive(false) on screenboxes? Thomas Brush inspiration
Hi I'm trying to make screen boxes/frames just like Thomas Brush made in one of his videos. Basically, the gameobject is not inside the camera's view. Then, they will be disabled, and once the player enters that part of the scene, it is enabled, and the other is disabled.
I'm working with two different scripts; A screenbox script and a game-manager script that controls when to disable the screenboxes.
The framescript is simply setting the dimension of DrawGizmo, but most important is it contains the public bool frameActive.
GameManager script: [Header("Scene Controller")] private static GameManagerScript _instance; public static GameManagerScript instance; [Space] public FrameScript InitialFrame; FrameScript currentFrame;
private void Start()
{
ChangeFrame(InitialFrame);
}
public void FixedUpdate()
{
if (currentFrame.frameActive == true)
{
currentFrame.gameObject.SetActive(true);
}
//Disable when frame is inactive
if (currentFrame.frameActive == false)
{
currentFrame.gameObject.SetActive(false);
}
}
public void ChangeFrame(FrameScript newFrame)
{
if ( currentFrame != null)
{
currentFrame.frameActive = false;
}
currentFrame = newFrame;
currentFrame.frameActive = true;
// Camera controller set camera bounds here
CameraController.instance.SetCamBounds(currentFrame.minCamPos + (Vector2)currentFrame.transform.position,
currentFrame.maxCamPos + (Vector2)currentFrame.transform.position);
}
So my question is how can I disable all Frames/Screenbox when they are inactive?