Last active
December 15, 2016 10:33
-
-
Save enue/69a3605d3cec5e51addea07c76dd68d2 to your computer and use it in GitHub Desktop.
[Unity] TimeScaler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
// Unity5.5.0p1 | |
namespace TSKT | |
{ | |
public class TimeScaler | |
{ | |
static Dictionary<System.Guid, float> scales = new Dictionary<System.Guid, float>(); | |
System.Guid guid = System.Guid.NewGuid(); | |
public void SetScale(float t) | |
{ | |
if (t == 1f) | |
{ | |
scales.Remove(guid); | |
} | |
else | |
{ | |
scales[guid] = t; | |
} | |
Time.timeScale = TotalScale; | |
} | |
float TotalScale | |
{ | |
get | |
{ | |
float t = 1f; | |
foreach(var it in scales) | |
{ | |
t *= it.Value; | |
} | |
return t; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment