Exemple #1
0
        public static void Init()
        {
            // Create SpriteData
            float     width   = Screens.min * 0.20f;
            Texture2D texture = SpriteLoader.GetTexture(Sprites.SANDBOX_MINE);

            _data = new SpriteAnimData(NAME, texture, width, 8);
        }
Exemple #2
0
    private void InitializePresetData(SpritePreset preset)
    {
        preset.datas.Clear();

        foreach (var clip in preset.clips)
        {
            var animData = new SpriteAnimData();
            animData.length = clip.length;

            foreach (var binding in AnimationUtility.GetObjectReferenceCurveBindings(clip))
            {
                foreach (var frame in AnimationUtility.GetObjectReferenceCurve(clip, binding))
                {
                    var sprite = (Sprite)frame.value;

                    animData.timelines.Add(new SpriteTimeline()
                    {
                        start   = frame.time,
                        texture = sprite.texture
                    });
                }
            }

            if (0 == animData.timelines.Count)
            {
                continue;
            }

            for (int i = 0; i < animData.timelines.Count - 1; ++i)
            {
                animData.timelines[i].end = animData.timelines[i + 1].start;
            }
            animData.timelines[animData.timelines.Count - 1].end = animData.length;

            animData.name = GetCutOffClipName(clip);

            var hash = 0;
            foreach (var c in animData.name)
            {
                hash += Convert.ToInt32(c);
            }

            preset.datas.Add(hash, animData);
        }
    }