Пример #1
0
    public static AlphaRef ColorAlpha(ClassRef <Color> color)
    {
        Func <float>   get = () => color.get().a;
        Action <float> set = (a) => {
            var col = color.get();
            col.a = a;
            color.set(col);
        };

        return(new AlphaRef(set, get));
    }
Пример #2
0
    public IEnumerator MoveToPos(Vector2 pos, float time, AnimationCurve timeDisCurve)
    {
        var   dir       = pos - posRef.get();
        var   dis       = dir.magnitude;
        var   originPos = posRef.get();
        float timeCount = 0;

        while (timeCount < 1)
        {
            yield return(null);

            timeCount += Time.unscaledDeltaTime / time;
            timeCount  = Mathf.Clamp01(timeCount);
            var normedDis = timeDisCurve.Evaluate(timeCount);
            posRef.set(originPos + dir.normalized * normedDis * dis);
        }
        yield break;
    }
Пример #3
0
 public static ClassRef <Color> SRGBToLiner(ClassRef <Color> srgb)
 {
     return(new ClassRef <Color>((c) => srgb.set(VectorUtils.Do(c, f => Mathf.Pow(f, 1 / 2.2f))), () => VectorUtils.Do(srgb.get(), f => Mathf.Pow(f, 2.2f))));
 }
Пример #4
0
 public void Start()
 {
     originPos = pivotRef.get();
 }