Create a gist now

Instantly share code, notes, and snippets.

@enue /TimeScaler.cs
Last active Dec 15, 2016

[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