2020-05-31 17:07:22 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using SanAndreasUnity.Behaviours.World;
|
|
|
|
|
using SanAndreasUnity.UI;
|
|
|
|
|
|
|
|
|
|
namespace SanAndreasUnity.Settings {
|
|
|
|
|
|
|
|
|
|
public class WorldSettings : MonoBehaviour {
|
|
|
|
|
|
2019-06-22 21:01:50 +00:00
|
|
|
|
static float s_maxDrawDistance = 500f;
|
|
|
|
|
|
2020-05-31 17:07:22 +00:00
|
|
|
|
OptionsWindow.FloatInput m_maxDrawDistanceInput = new OptionsWindow.FloatInput() {
|
|
|
|
|
description = "Max draw distance",
|
|
|
|
|
minValue = 50,
|
|
|
|
|
maxValue = 1000,
|
2019-06-22 21:01:50 +00:00
|
|
|
|
getValue = () => Cell.Instance != null ? Cell.Instance.maxDrawDistance : s_maxDrawDistance,
|
|
|
|
|
setValue = (value) => { s_maxDrawDistance = value; if (Cell.Instance != null) Cell.Instance.maxDrawDistance = value; },
|
|
|
|
|
persistType = OptionsWindow.InputPersistType.OnStart
|
2020-05-31 17:07:22 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Awake ()
|
|
|
|
|
{
|
|
|
|
|
OptionsWindow.RegisterInputs ("WORLD", m_maxDrawDistanceInput);
|
2019-06-22 21:01:50 +00:00
|
|
|
|
UnityEngine.SceneManagement.SceneManager.activeSceneChanged += (s1, s2) => OnActiveSceneChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnActiveSceneChanged()
|
|
|
|
|
{
|
|
|
|
|
// apply settings
|
|
|
|
|
|
|
|
|
|
// we need to find Cell with FindObjectOfType(), because it's Awake() method may have not been called yet
|
|
|
|
|
Cell cell = Object.FindObjectOfType<Cell>();
|
|
|
|
|
if (cell != null)
|
|
|
|
|
cell.maxDrawDistance = s_maxDrawDistance;
|
|
|
|
|
|
2020-05-31 17:07:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|