using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using Random = UnityEngine.Random;
namespace Utils
{
public static class Extensions
{
///
/// Get all interfaces in the given scene
///
public static List FindInterfaces(this Scene scene)
{
var interfaces = new List();
var rootGameObjects = scene.GetRootGameObjects();
foreach (var rootGameObject in rootGameObjects)
{
var childrenInterfaces = rootGameObject.GetComponentsInChildren();
foreach (var childInterface in childrenInterfaces)
interfaces.Add(childInterface);
}
return interfaces;
}
public static float EvaluateMinMaxCurve(this ParticleSystem.MinMaxCurve curve, int t = 0)
{
switch (curve.mode)
{
case ParticleSystemCurveMode.Constant:
return curve.constant;
case ParticleSystemCurveMode.Curve:
return curve.Evaluate(t);
case ParticleSystemCurveMode.TwoCurves:
return curve.EvaluateMinMaxCurve(t);
case ParticleSystemCurveMode.TwoConstants:
return Random.Range(curve.constantMin, curve.constantMax);
default:
throw new ArgumentOutOfRangeException();
}
}
}
}