Singularity/Library/PackageCache/com.unity.2d.pixel-perfect@.../Samples~/Scenes and Extras/Scenes/Scripts/CameraManager.cs

38 lines
820 B
C#
Raw Permalink Normal View History

2024-05-06 14:45:45 -04:00
using System;
using UnityEngine;
using UnityEngine.U2D;
public class CameraManager : MonoBehaviour
{
public Camera ordinaryCamera;
public PixelPerfectCamera pixelPerfectCamera;
private bool isPixelPerfect;
void Awake()
{
isPixelPerfect = false;
ValidateCameras(isPixelPerfect);
}
public void TogglePixelPerfect(bool value)
{
isPixelPerfect = value;
ValidateCameras(isPixelPerfect);
}
public void ValidateCameras(bool value)
{
if (value)
{
ordinaryCamera.gameObject.SetActive(false);
pixelPerfectCamera.gameObject.SetActive(true);
}
else
{
ordinaryCamera.gameObject.SetActive(true);
pixelPerfectCamera.gameObject.SetActive(false);
}
}
}