Example #1
0
        public override void Serialize(ExporterEntry entry, Dictionary <string, Extension> extensions, UnityEngine.Object component = null)
        {
            var animator  = component as SeinAnimator;
            var extension = new Sein_animatorExtension();

            extension.name             = animator.name;
            extension.prefixes         = animator.prefixes;
            extension.defaultAnimation = animator.defaultAnimation;
            extension.modelAnimations  = animator.modelAnimations;

            AddExtension(extensions, extension);
        }
Example #2
0
        public override Extension Deserialize(GLTFRoot root, JProperty extensionToken)
        {
            var extension = new Sein_animatorExtension();

            if (extensionToken != null)
            {
                extension.defaultAnimation = (string)extensionToken.Value["defaultAnimation"];
                extension.modelAnimations  = extensionToken.Value["modelAnimations"].ToObject <string[]>();
                if (extensionToken.Value["prefix"] != null)
                {
                    extension.prefix = (string)extensionToken.Value["prefix"];
                }
                if (extensionToken.Value["prefixes"] != null)
                {
                    extension.prefixes = extensionToken.Value["prefixes"].ToObject <string[]>();
                }
                if (extensionToken.Value["name"] != null)
                {
                    extension.name = (string)extensionToken.Value["name"];
                }
            }

            var list       = new List <string>(extension.modelAnimations);
            var hasDefault = extension.defaultAnimation != null && extension.defaultAnimation != "" && list.Contains(extension.defaultAnimation);

            if (hasDefault)
            {
                list.Remove(extension.defaultAnimation);
            }

            Array.Sort(extension.modelAnimations);

            if (hasDefault)
            {
                list.Insert(0, extension.defaultAnimation);
            }

            return(extension);
        }