Beispiel #1
0
        // update cache (optimized)
        public override void updateCache()
        {
            // destroy cache
            destroyCache(); //undo handled inside
            // create new cache
            _clearCache();  //undo handled inside
            // sort keys
            sortKeys();     //undo handled inside

            for (int i = 0; i < keys.Count; i++)
            {
                AMAnimatorAction a = ScriptableObject.CreateInstance <AMAnimatorAction>();
                a.startFrame = keys[i].frame;
                //if (keys.Count > (i + 1))
                //    a.endFrame = keys[i + 1].frame;
                //else
                //    a.endFrame = -1;

                AMAnimatorKey k = (AMAnimatorKey)keys[i];
                a.obj = obj;
                a.CopyKeyInfos(k.infos);

                a.easeType   = (keys[i] as AMAnimatorKey).easeType;
                a.customEase = new List <float>(keys[i].customEase);
                // add to cache
                cache.Add(a);
            }
        }
Beispiel #2
0
        // copy properties from key
        public override AMKey CreateClone()
        {
            AMAnimatorKey a = ScriptableObject.CreateInstance <AMAnimatorKey>();

            a.frame      = frame;
            a.easeType   = easeType;
            a.customEase = new List <float>(customEase);

            for (int i = 0; i < m_infos.Count; ++i)
            {
                var newInst = new AnimatorKeyInfo(m_infos[i]);
                a.m_infos.Add(newInst);
            }

            return(a);
        }
Beispiel #3
0
        // add a new key
        // the parameters should be set by AMTimeline inspector
        public void addKey(int _frame)
        {
            foreach (AMAnimatorKey key in keys)
            {
                // if key exists on frame, update key
                if (key.frame == _frame)
                {
                    AMUtil.recordObject(key, "update key");
                    // update cache
                    updateCache();
                    return;
                }
            }

            AMAnimatorKey a = ScriptableObject.CreateInstance <AMAnimatorKey>();

            a.frame    = _frame;
            a.easeType = (int)AMTween.EaseType.linear;
            // add a new key
            AMUtil.recordObject(this, "add key");
            keys.Add(a);
            // update cache
            updateCache();
        }