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

38 lines
820 B
C#
Raw Normal View History

2022-01-12 10:06:03 +03: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);
}
}
}