2020-05-31 17:07:22 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using SanAndreasUnity.UI;
|
|
|
|
|
|
|
|
|
|
namespace SanAndreasUnity.Settings {
|
|
|
|
|
|
|
|
|
|
public class CameraSettings : MonoBehaviour {
|
|
|
|
|
|
2019-06-22 21:19:28 +00:00
|
|
|
|
static float s_farClipPlane = 1000;
|
|
|
|
|
static float s_fieldOfView = 60;
|
|
|
|
|
|
2020-05-31 17:07:22 +00:00
|
|
|
|
OptionsWindow.FloatInput m_farClipPlaneInput = new OptionsWindow.FloatInput() {
|
|
|
|
|
description = "Far clip plane",
|
|
|
|
|
minValue = 100,
|
|
|
|
|
maxValue = 5000,
|
2019-06-22 21:19:28 +00:00
|
|
|
|
getValue = () => Camera.main != null ? Camera.main.farClipPlane : s_farClipPlane,
|
|
|
|
|
setValue = (value) => { s_farClipPlane = value; if (Camera.main != null) Camera.main.farClipPlane = value; },
|
2019-06-23 02:00:38 +00:00
|
|
|
|
persistType = OptionsWindow.InputPersistType.OnStart,
|
2020-05-31 17:07:22 +00:00
|
|
|
|
};
|
|
|
|
|
OptionsWindow.FloatInput m_fieldOfViewInput = new OptionsWindow.FloatInput() {
|
|
|
|
|
description = "Field of view",
|
|
|
|
|
minValue = 20,
|
|
|
|
|
maxValue = 120,
|
2019-06-22 21:19:28 +00:00
|
|
|
|
getValue = () => Camera.main != null ? Camera.main.fieldOfView : s_fieldOfView,
|
|
|
|
|
setValue = (value) => { s_fieldOfView = value; if (Camera.main != null) Camera.main.fieldOfView = value; },
|
2019-06-23 02:00:38 +00:00
|
|
|
|
persistType = OptionsWindow.InputPersistType.OnStart,
|
2020-05-31 17:07:22 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Awake ()
|
|
|
|
|
{
|
|
|
|
|
OptionsWindow.RegisterInputs ("CAMERA", m_farClipPlaneInput, m_fieldOfViewInput);
|
2019-06-22 21:19:28 +00:00
|
|
|
|
UnityEngine.SceneManagement.SceneManager.activeSceneChanged += (s1, s2) => OnActiveSceneChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnActiveSceneChanged()
|
|
|
|
|
{
|
|
|
|
|
// apply settings
|
|
|
|
|
|
|
|
|
|
Camera cam = Utilities.F.FindMainCameraEvenIfDisabled();
|
|
|
|
|
if (cam != null)
|
|
|
|
|
{
|
|
|
|
|
cam.farClipPlane = s_farClipPlane;
|
|
|
|
|
cam.fieldOfView = s_fieldOfView;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 17:07:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|