Exemplo n.º 1
0
        protected override void DoCopy(AMTrack track)
        {
            AMTranslationTrack ntrack = track as AMTranslationTrack;

            ntrack._obj = _obj;
            ntrack.cachedInitialPosition = cachedInitialPosition;
            ntrack.pixelSnap             = pixelSnap;
            ntrack.pixelPerUnit          = pixelPerUnit;
        }
Exemplo n.º 2
0
        public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object obj)
        {
            int frameRate = seq.take.frameRate;

            //allow tracks with just one key
            if (track.keys.Count == 1)
            {
                interp = (int)Interpolation.None;
            }

            Transform trans = obj as Transform;

            AMTranslationTrack tTrack = track as AMTranslationTrack;
            bool  pixelSnap           = tTrack.pixelSnap;
            float ppu = tTrack.pixelPerUnit;

            if (!canTween)
            {
                //TODO: world position
                Vector3 pos = pixelSnap ? new Vector3(Mathf.Round(position.x * ppu) / ppu, Mathf.Round(position.y * ppu) / ppu, Mathf.Round(position.z * ppu) / ppu) : position;

                var tweener = DOTween.To(new AMPlugValueSet <Vector3>(), () => pos, (x) => trans.localPosition = x, pos, getTime(frameRate));
                tweener.plugOptions = new AMPlugValueSetOptions(seq.sequence);

                seq.Insert(this, tweener);
            }
            else
            {
                if (path.Length <= 1)
                {
                    return;
                }
                if (getNumberOfFrames(seq.take.frameRate) <= 0)
                {
                    return;
                }

                Tweener ret = null;

                bool isRelative = false;

                PathType pathType = path.Length == 2 ? PathType.Linear : PathType.CatmullRom;

                if (pixelSnap)
                {
                    ret = DOTween.To(new PlugVector3PathSnap(ppu), () => trans.localPosition, x => trans.localPosition = x, new Path(pathType, path, pathResolution), getTime(frameRate)).SetRelative(isRelative).SetOptions(isClosed);
                }
                else
                {
                    ret = trans.DOLocalPath(path, getTime(frameRate), pathType, PathMode.Full3D, pathResolution, null).SetRelative(isRelative).SetOptions(isClosed);
                }

                if (hasCustomEase())
                {
                    ret.SetEase(easeCurve);
                }
                else
                {
                    ret.SetEase((Ease)easeType, amplitude, period);
                }

                seq.Insert(this, ret);
            }
        }