Assets/Utils/TagAttribute.cs
Assets/Utils/LayerAttribute.cs
[Tag]
public string targetTag;
[Layer]
public int targetLayer;
// [Range(0,10f)]
// public float otherValue;
[SerializeField, MinMaxRange(0,10f)]
MinMax randomDelayRange;
float delay;
float accum;
void Update () {
accum += Time.deltaTime;
if (accum >= delay) {
Debug.Log ("Fire!");
accum = 0;
delay = randomDelayRange.randomValue;
}
}
Assets/Utils/PlayerPrefsData.cs
Helper for saving objects with PlayerPrefs.
// Custom Class to save with PlayerPrefs
public class AudioSettings
{
public float bgmVolume = 1f;
public float seVolume = 1f;
}
void LoadData ()
{
var data = PlayerPrefsData<AudioSettings>.Load (
// Default Value
new AudioSettings ()
);
m_BgmVolumeSlider.value = data.bgmVolume;
m_SeVolumeSlider.value = data.seVolume;
}
void SaveData ()
{
var data = new AudioSettings ();
data.bgmVolume = m_BgmVolumeSlider.value;
data.seVolume = m_SeVolumeSlider.value;
PlayerPrefsData<AudioSettings>.Save (data);
}
void ResetData ()
{
PlayerPrefsData<AudioSettings>.Delete ();
// Reload
LoadData ();
}