34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame
|
|
{
|
|
public class CameraVignetteEffect : MonoBehaviour
|
|
{
|
|
public ParticleSystem mainEffect;
|
|
public Transform scaler;
|
|
public ParticleSystem vignetteEffect;
|
|
|
|
public void Initialize()
|
|
{
|
|
float standardRatio = 16f / 9f;
|
|
float screenRatio = (float)Screen.width / Screen.height;
|
|
|
|
Vector3 standardScale = new Vector3(1.6f, 0.9f, 1);
|
|
|
|
if (screenRatio > standardRatio)
|
|
{
|
|
float scaleFactor = screenRatio / standardRatio;
|
|
scaler.localScale = new Vector3(standardScale.x * scaleFactor, standardScale.y, standardScale.z);
|
|
}
|
|
else if (screenRatio < standardRatio)
|
|
{
|
|
float scaleFactor = standardRatio / screenRatio;
|
|
scaler.localScale = new Vector3(standardScale.x, standardScale.y * scaleFactor, standardScale.z);
|
|
}
|
|
else
|
|
{
|
|
scaler.localScale = standardScale;
|
|
}
|
|
}
|
|
}
|
|
} |