Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- namespace StylizedWater3.Examples
- {
- [ExecuteAlways]
- public class SetWaterTimeOffset : MonoBehaviour
- {
- public enum Mode
- {
- None,
- Interval,
- Time,
- EditorTime,
- Custom
- }
- public Mode mode = Mode.Custom;
- public float interval = 0.2f;
- public float customTime = 0f;
- private float elapsedTime;
- void Update()
- {
- if (mode == Mode.None)
- {
- OnDisable();
- return;
- }
- if (mode == Mode.Interval)
- {
- elapsedTime += Time.deltaTime;
- if (elapsedTime >= interval)
- {
- elapsedTime = 0;
- StylizedWater3.WaterObject.CustomTime = Time.time;
- }
- }
- if (mode == Mode.Time)
- {
- StylizedWater3.WaterObject.CustomTime = Time.time;
- }
- #if UNITY_EDITOR
- if (mode == Mode.EditorTime)
- {
- StylizedWater3.WaterObject.CustomTime = (float)UnityEditor.EditorApplication.timeSinceStartup;
- }
- #endif
- if (mode == Mode.Custom)
- {
- StylizedWater3.WaterObject.CustomTime = customTime;
- }
- }
- private void OnDisable()
- {
- //Revert to using normal time
- StylizedWater3.WaterObject.CustomTime = -1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement