Skip to content

Instantly share code, notes, and snippets.

@enue
Last active December 15, 2016 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enue/69a3605d3cec5e51addea07c76dd68d2 to your computer and use it in GitHub Desktop.
Save enue/69a3605d3cec5e51addea07c76dd68d2 to your computer and use it in GitHub Desktop.
[Unity] TimeScaler
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