Ejemplo n.º 1
0
        // update cache (optimized)
        public override void updateCache(ITarget target)
        {
            base.updateCache(target);

            for (int i = 0; i < keys.Count; i++)
            {
                ScaleKey key = keys[i] as ScaleKey;

                key.GeneratePath(this, i);

                //invalidate some keys in between
                if (key.path != null)
                {
                    int endInd = i + key.keyCount - 1;
                    if (endInd < keys.Count - 1 || key.interp != keys[endInd].interp) //don't count the last element if there are more keys ahead
                    {
                        endInd--;
                    }

                    for (int j = i + 1; j <= endInd; j++)
                    {
                        var _key = keys[j] as ScaleKey;

                        _key.interp   = key.interp;
                        _key.easeType = key.easeType;
                        _key.Invalidate();
                    }

                    i = endInd;
                }
            }
        }
Ejemplo n.º 2
0
        // add a new key
        public void addKey(ITarget target, int _frame, Vector3 _scale)
        {
            foreach (ScaleKey key in keys)
            {
                // if key exists on frame, update key
                if (key.frame == _frame)
                {
                    key.scale = _scale;
                    // update cache
                    updateCache(target);
                    return;
                }
            }
            var a = new ScaleKey();

            a.frame = _frame;
            a.scale = _scale;
            // set default ease type to linear
            a.easeType = Ease.Linear;

            // add a new key
            keys.Add(a);
            // update cache
            updateCache(target);
        }
Ejemplo n.º 3
0
        // add a new key
        public void addKey(ITarget target, int _frame, Vector3 _scale)
        {
            ScaleKey prevKey = null;

            foreach (ScaleKey key in keys)
            {
                // if key exists on frame, update key
                if (key.frame == _frame)
                {
                    key.scale = _scale;
                    // update cache
                    updateCache(target);
                    return;
                }
                else if (key.frame < _frame)
                {
                    prevKey = key;
                }
            }

            var a = new ScaleKey();

            a.frame = _frame;
            a.scale = _scale;

            // copy interpolation and ease type from previous
            if (prevKey != null)
            {
                a.interp    = prevKey.interp;
                a.easeType  = prevKey.easeType;
                a.easeCurve = prevKey.easeCurve;
            }
            else   //set default
            {
                a.interp   = Key.Interpolation.Curve;
                a.easeType = Ease.Linear;
            }

            // add a new key
            keys.Add(a);
            // update cache
            updateCache(target);
        }
Ejemplo n.º 4
0
        // update cache (optimized)
        public override void updateCache(ITarget target)
        {
            base.updateCache(target);

            for (int i = 0; i < keys.Count; i++)
            {
                ScaleKey key = keys[i] as ScaleKey;

                key.version = version;
                key.GeneratePath(this, i);
                key.ClearCache();

                //invalidate some keys in between
                if (key.path.Length > 1)
                {
                    int endInd = i + key.path.Length - 1;
                    if (endInd < keys.Count - 1 || key.interp != keys[endInd].interp) //don't count the last element if there are more keys ahead
                    {
                        endInd--;
                    }

                    for (int j = i + 1; j <= endInd; j++)
                    {
                        var _key = keys[j] as ScaleKey;

                        _key.version  = version;
                        _key.interp   = key.interp;
                        _key.easeType = key.easeType;
                        _key.endFrame = -1;
                        _key.path     = new Vector3[0];
                    }

                    i = endInd;
                }
            }
        }