SpriteStudioForUnity.SpriteStudioBaker.CreateAnimator C# (CSharp) Méthode

CreateAnimator() public méthode

public CreateAnimator ( SpriteStudioAnimePack animePack ) : void
animePack SpriteStudioAnimePack
Résultat void
        public void CreateAnimator(SpriteStudioAnimePack animePack)
        {
            GameObject controllerObj = new GameObject (animePack.name);
            SSController controller = controllerObj.AddComponent<SSController> ();

            GameObject animatorObj = new GameObject ("animator");
            animatorObj.transform.parent = controllerObj.transform;
            AnimationEventListener listener = animatorObj.AddComponent<AnimationEventListener> ();

            List<SSCell> cellList = new List<SSCell> ();
            int mapId = 0;
            int cellId = 0;
            foreach (string cellmapName in animePack.cellmapNames) {
                SpriteStudioCellMap cellMap = cellMapList.FirstOrDefault (u => u.cellmapName == cellmapName);
                List<SSCell> cells = cellMaps [cellMap.cellmapName];
                foreach (SSCell cell in cells) {
                    cell.mapId = mapId;
                    cell.cellId = cellId;
                    cellList.Add (cell);
                    cellId++;
                }
                mapId++;
            }
            controller.cellList = cellList;

            List<SSPart> partList = new List<SSPart> ();

            foreach (SpriteStudioAnimePackModelValue model in animePack.Model.partList) {
                GameObject partObj = new GameObject (model.name);
                SSPart part = partObj.AddComponent<SSPart> ();
                part.controller = controller;
                part.name = model.name;
                part.arrayIndex = model.arrayIndex;
                part.parentIndex = model.parentIndex;
                part.partType = model.type.ToPartType ();
                part.boundsType = model.boundsType.ToBoundType ();
                part.alphaBlendType = model.alphaBlendType.ToAlphaBlendType ();
                part.inheritType = model.inheritType.ToInheritType ();
                if (model.ineheritRates != null) {
                    part.inheritAlph = model.ineheritRates.ALPH == 1;
                    part.inheritFlph = model.ineheritRates.FLPH == 1;
                    part.inheritFlpv = model.ineheritRates.FLPV == 1;
                    part.inheritHide = model.ineheritRates.HIDE == 1;
                    part.inheritIflh = model.ineheritRates.IFLH == 1;
                    part.inheritIflv = model.ineheritRates.IFLV == 1;
                }
                partList.Add (part);

                if (part.parentIndex == -1) {
                    partObj.transform.parent = listener.transform;
                    part.path = part.name;
                } else {
                    SSPart parentPart = partList.SingleOrDefault (v => v.arrayIndex == model.parentIndex);
                    if (parentPart != null) {
                        partObj.transform.parent = parentPart.transform;
                        part.path = parentPart.path + "/" + part.name;
                        part.parent = parentPart;
                    }
                }
            }

            controller.partList = partList;

            string animatorPath = animationsDirectory + "/" + animePack.name + ".controller";
            AnimatorController animatorController = AnimatorController.CreateAnimatorControllerAtPath (animatorPath);
            Animator animator = listener.GetComponent<Animator> ();
            animator.runtimeAnimatorController = animatorController;

            foreach (SpriteStudioAnimePackAnime packAnime in animePack.animeList) {
                AnimationClip clip = new AnimationClip ();
                clip.name = packAnime.name;
                clip.frameRate = packAnime.settings.fps;
                int frameCount = packAnime.settings.frameCount;

                AnimationClipSettings settings = AnimationUtility.GetAnimationClipSettings (clip);
                settings.loopTime = true;
                AnimationUtility.SetAnimationClipSettings (clip, settings);

                animatorController.AddMotion (clip);
                AssetDatabase.AddObjectToAsset (clip, animatorController);

                foreach (SpriteStudioAnimePackAnimePartAnime partAnime in packAnime.partAnimes) {
                    SSPart part = partList.SingleOrDefault (v => v.name == partAnime.partName);
                    SpriteStudioAnimePackAnimePartAnimeAttribute attribute = null;
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "CELL");
                    if (attribute != null) {
                        AnimationCurve curveCellId = new AnimationCurve ();
                        for (int i = 0; i < attribute.key.Length; i++) {
                            SpriteStudioAnimePackAnimePartAnimeAttributeKey key = attribute.key [i];
                            float time = GetTime (key.time, clip.frameRate);
                            SSCell cell = cellList.SingleOrDefault (v => v.mapId == key.value.mapId && v.name == key.value.name);
                            curveCellId.AddKey (KeyframeUtil.GetNew (time, (float)cell.cellId, TangentMode.Stepped));
                        }
                        clip.SetCurve (part.path, typeof(SSPart), "cellId", curveCellId);
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "POSX");
                    if (attribute != null) {
                        AnimationCurve curve = new AnimationCurve ();
                        SetFloatCurve (curve, attribute, clip.frameRate, frameCount);
                        clip.SetCurve (part.path, typeof(SSPart), "pos.x", curve);
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "POSY");
                    if (attribute != null) {
                        AnimationCurve curve = new AnimationCurve ();
                        SetFloatCurve (curve, attribute, clip.frameRate, frameCount);
                        clip.SetCurve (part.path, typeof(SSPart), "pos.y", curve);
                    }
                    if(animePack.settings.sortMode == "z"){
                        attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "POSZ");
                        if (attribute != null) {
                            AnimationCurve curve = new AnimationCurve ();
                            SetFloatCurve (curve, attribute, clip.frameRate, frameCount);
                            clip.SetCurve (part.path, typeof(SSPart), "pos.z", curve);
                        } else {
                            AnimationCurve curve = new AnimationCurve ();
                            float endTime = GetTime (frameCount - 1, clip.frameRate);
                            curve.AddKey (KeyframeUtil.GetNew (0, 0, TangentMode.Stepped));
                            curve.AddKey (KeyframeUtil.GetNew (endTime, 0, TangentMode.Stepped));
                            clip.SetCurve (part.path, typeof(SSPart), "pos.z", curve);
                        }
                    }else if(animePack.settings.sortMode == "prio"){
                        attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "PRIO");
                        if (attribute != null) {
                            AnimationCurve curve = new AnimationCurve ();
                            SetFloatCurve (curve, attribute, clip.frameRate, frameCount);
                            clip.SetCurve (part.path, typeof(SSPart), "pos.z", curve);
                        } else {
                            AnimationCurve curve = new AnimationCurve ();
                            float endTime = GetTime (frameCount - 1, clip.frameRate);
                            curve.AddKey (KeyframeUtil.GetNew (0, 0, TangentMode.Stepped));
                            curve.AddKey (KeyframeUtil.GetNew (endTime, 0, TangentMode.Stepped));
                            clip.SetCurve (part.path, typeof(SSPart), "pos.z", curve);
                        }
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "ROTX");
                    if (attribute != null) {
                        AnimationCurve curve = new AnimationCurve ();
                        SetFloatCurve (curve, attribute, clip.frameRate, frameCount);
                        clip.SetCurve (part.path, typeof(SSPart), "rot.x", curve);
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "ROTY");
                    if (attribute != null) {
                        AnimationCurve curve = new AnimationCurve ();
                        SetFloatCurve (curve, attribute, clip.frameRate, frameCount);
                        clip.SetCurve (part.path, typeof(SSPart), "rot.y", curve);
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "ROTZ");
                    if (attribute != null) {
                        AnimationCurve curve = new AnimationCurve ();
                        SetFloatCurve (curve, attribute, clip.frameRate, frameCount);
                        clip.SetCurve (part.path, typeof(SSPart), "rot.z", curve);
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "SCLX");
                    if (attribute != null) {
                        AnimationCurve curve = new AnimationCurve ();
                        SetFloatCurve (curve, attribute, clip.frameRate, frameCount);
                        clip.SetCurve (part.path, typeof(Transform), "localScale.x", curve);
                    }else {
                        AnimationCurve curve = new AnimationCurve ();
                        float endTime = GetTime (frameCount - 1, clip.frameRate);
                        curve.AddKey (KeyframeUtil.GetNew (0, 1, TangentMode.Stepped));
                        curve.AddKey (KeyframeUtil.GetNew (endTime, 1, TangentMode.Stepped));
                        clip.SetCurve (part.path, typeof(Transform), "localScale.x", curve);
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "SCLY");
                    if (attribute != null) {
                        AnimationCurve curve = new AnimationCurve ();
                        SetFloatCurve (curve, attribute, clip.frameRate, frameCount);
                        clip.SetCurve (part.path, typeof(Transform), "localScale.y", curve);
                    }else{
                        AnimationCurve curve = new AnimationCurve ();
                        float endTime = GetTime (frameCount - 1, clip.frameRate);
                        curve.AddKey (KeyframeUtil.GetNew (0, 1, TangentMode.Stepped));
                        curve.AddKey (KeyframeUtil.GetNew (endTime, 1, TangentMode.Stepped));
                        clip.SetCurve (part.path, typeof(Transform), "localScale.y", curve);
                    }
                    {
                        AnimationCurve curve = new AnimationCurve ();
                        float endTime = GetTime (frameCount - 1, clip.frameRate);
                        curve.AddKey (KeyframeUtil.GetNew (0, 1, TangentMode.Stepped));
                        curve.AddKey (KeyframeUtil.GetNew (endTime, 1, TangentMode.Stepped));
                        clip.SetCurve (part.path, typeof(Transform), "localScale.z", curve);
                    }					attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "ALPH");
                    if (attribute != null) {
                        AnimationCurve curve = new AnimationCurve ();
                        SetFloatCurve (curve, attribute, clip.frameRate, frameCount);
                        clip.SetCurve (part.path, typeof(SSPart), "alpha", curve);
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "FLPH");
                    if (attribute != null) {
                        AnimationCurve curve = new AnimationCurve ();
                        SetBoolCurve (curve, attribute, clip.frameRate);
                        clip.SetCurve (part.path, typeof(SSPart), "flpH", curve);
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "FLPV");
                    if (attribute != null) {
                        AnimationCurve curve = new AnimationCurve ();
                        SetBoolCurve (curve, attribute, clip.frameRate);
                        clip.SetCurve (part.path, typeof(SSPart), "flpV", curve);
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "HIDE");
                    if (attribute != null) {
                        AnimationCurve curve = new AnimationCurve ();
                        for (int i = 0; i < attribute.key.Length; i++) {
                            SpriteStudioAnimePackAnimePartAnimeAttributeKey key = attribute.key [i];
                            float time = GetTime (key.time, clip.frameRate);
                            float value = GetValue (key) == 0 ? 1 : 0;
                            if (i == 0 && time != 0) {
                                curve.AddKey (KeyframeUtil.GetNew (0, 0, TangentMode.Stepped));
                            }
                            curve.AddKey (KeyframeUtil.GetNew (time, value, TangentMode.Stepped));
                        }
                        clip.SetCurve (part.path, typeof(MeshRenderer), "m_Enabled", curve);
                    } else {
                        AnimationCurve curve = new AnimationCurve ();
                        curve.AddKey (KeyframeUtil.GetNew (0, 0, TangentMode.Stepped));
                        clip.SetCurve (part.path, typeof(MeshRenderer), "m_Enabled", curve);
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "PVTX");
                    if (attribute != null) {
                        AnimationCurve curve = new AnimationCurve ();
                        SetFloatCurve (curve, attribute, clip.frameRate, frameCount);
                        clip.SetCurve (part.path, typeof(SSPart), "pvt.x", curve);
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "PVTY");
                    if (attribute != null) {
                        AnimationCurve curve = new AnimationCurve ();
                        SetFloatCurve (curve, attribute, clip.frameRate, frameCount);
                        clip.SetCurve (part.path, typeof(SSPart), "pvt.y", curve);
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "ANCX");
                    if (attribute != null) {
                        AnimationCurve curve = new AnimationCurve ();
                        SetFloatCurve (curve, attribute, clip.frameRate, frameCount);
                        clip.SetCurve (part.path, typeof(SSPart), "anc.x", curve);
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "ANCY");
                    if (attribute != null) {
                        AnimationCurve curve = new AnimationCurve ();
                        SetFloatCurve (curve, attribute, clip.frameRate, frameCount);
                        clip.SetCurve (part.path, typeof(SSPart), "anc.y", curve);
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "SIZX");
                    if (attribute != null) {
                        AnimationCurve curve = new AnimationCurve ();
                        SetFloatCurve (curve, attribute, clip.frameRate, frameCount);
                        clip.SetCurve (part.path, typeof(SSPart), "siz.x", curve);
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "SIZY");
                    if (attribute != null) {
                        AnimationCurve curve = new AnimationCurve ();
                        SetFloatCurve (curve, attribute, clip.frameRate, frameCount);
                        clip.SetCurve (part.path, typeof(SSPart), "siz.y", curve);
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "UVTX");
                    if (attribute != null) {
                        AnimationCurve curve = new AnimationCurve ();
                        SetFloatCurve (curve, attribute, clip.frameRate, frameCount);
                        clip.SetCurve (part.path, typeof(SSPart), "uvt.x", curve);
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "UVTY");
                    if (attribute != null) {
                        AnimationCurve curve = new AnimationCurve ();
                        SetFloatCurve (curve, attribute, clip.frameRate, frameCount);
                        clip.SetCurve (part.path, typeof(SSPart), "uvt.y", curve);
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "VCOL");
                    if (attribute != null) {
                        AnimationCurve curveBlend = new AnimationCurve ();
                        AnimationCurve curveLBR = new AnimationCurve ();
                        AnimationCurve curveLBG = new AnimationCurve ();
                        AnimationCurve curveLBB = new AnimationCurve ();
                        AnimationCurve curveLBA = new AnimationCurve ();
                        AnimationCurve curveRBR = new AnimationCurve ();
                        AnimationCurve curveRBG = new AnimationCurve ();
                        AnimationCurve curveRBB = new AnimationCurve ();
                        AnimationCurve curveRBA = new AnimationCurve ();
                        AnimationCurve curveLTR = new AnimationCurve ();
                        AnimationCurve curveLTG = new AnimationCurve ();
                        AnimationCurve curveLTB = new AnimationCurve ();
                        AnimationCurve curveLTA = new AnimationCurve ();
                        AnimationCurve curveRTR = new AnimationCurve ();
                        AnimationCurve curveRTG = new AnimationCurve ();
                        AnimationCurve curveRTB = new AnimationCurve ();
                        AnimationCurve curveRTA = new AnimationCurve ();
                        AnimationCurve curveRateLB = new AnimationCurve ();
                        AnimationCurve curveRateRB = new AnimationCurve ();
                        AnimationCurve curveRateLT = new AnimationCurve ();
                        AnimationCurve curveRateRT = new AnimationCurve ();

                        for (int i = 0; i < attribute.key.Length; i++) {
                            SpriteStudioAnimePackAnimePartAnimeAttributeKey key = attribute.key [i];
                            float time = GetTime (key.time, clip.frameRate);
                            ColorBlendTarget target = key.value.target.ToColorBlendTarget ();
                            ColorBlendType type = key.value.blendType.ToColorBlendType ();
                            float coorBlendValue = (float)type + 1.0f;
                            float valueLBR, valueLBG, valueLBB, valueLBA, valueRBR, valueRBG, valueRBB, valueRBA, valueLTR, valueLTG, valueLTB, valueLTA, valueRTR, valueRTG, valueRTB, valueRTA, rateLB, rateRB, rateLT, rateRT;

                            if (target == ColorBlendTarget.Whole) {
                                valueLBA = valueRBA = valueLTA = valueRTA = System.Int32.Parse (key.value.color.rgba.Substring (0, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                valueLBR = valueRBR = valueLTR = valueRTR = System.Int32.Parse (key.value.color.rgba.Substring (2, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                valueLBG = valueRBG = valueLTG = valueRTG = System.Int32.Parse (key.value.color.rgba.Substring (4, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                valueLBB = valueRBB = valueLTB = valueRTB = System.Int32.Parse (key.value.color.rgba.Substring (6, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                rateLB = rateRB = rateLT = rateRT = key.value.color.rate;
                            } else {
                                valueLBA = System.Int32.Parse (key.value.LB.rgba.Substring (0, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                valueLBR = System.Int32.Parse (key.value.LB.rgba.Substring (2, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                valueLBG = System.Int32.Parse (key.value.LB.rgba.Substring (4, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                valueLBB = System.Int32.Parse (key.value.LB.rgba.Substring (6, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                valueRBA = System.Int32.Parse (key.value.RB.rgba.Substring (0, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                valueRBR = System.Int32.Parse (key.value.RB.rgba.Substring (2, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                valueRBG = System.Int32.Parse (key.value.RB.rgba.Substring (4, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                valueRBB = System.Int32.Parse (key.value.RB.rgba.Substring (6, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                valueLTA = System.Int32.Parse (key.value.LT.rgba.Substring (0, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                valueLTR = System.Int32.Parse (key.value.LT.rgba.Substring (2, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                valueLTG = System.Int32.Parse (key.value.LT.rgba.Substring (4, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                valueLTB = System.Int32.Parse (key.value.LT.rgba.Substring (6, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                valueRTA = System.Int32.Parse (key.value.RT.rgba.Substring (0, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                valueRTR = System.Int32.Parse (key.value.RT.rgba.Substring (2, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                valueRTG = System.Int32.Parse (key.value.RT.rgba.Substring (4, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                valueRTB = System.Int32.Parse (key.value.RT.rgba.Substring (6, 2), System.Globalization.NumberStyles.HexNumber) / 255.0f;
                                rateLB = key.value.LB.rate;
                                rateRB = key.value.RB.rate;
                                rateLT = key.value.LT.rate;
                                rateRT = key.value.RT.rate;
                            }

                            curveBlend.AddKey (KeyframeUtil.GetNew (time, coorBlendValue, tangentMode));
                            curveLBR.AddKey (KeyframeUtil.GetNew (time, valueLBR, tangentMode));
                            curveLBG.AddKey (KeyframeUtil.GetNew (time, valueLBG, tangentMode));
                            curveLBB.AddKey (KeyframeUtil.GetNew (time, valueLBB, tangentMode));
                            curveLBA.AddKey (KeyframeUtil.GetNew (time, rateLB, tangentMode));
                            curveRBR.AddKey (KeyframeUtil.GetNew (time, valueRBR, tangentMode));
                            curveRBG.AddKey (KeyframeUtil.GetNew (time, valueRBG, tangentMode));
                            curveRBB.AddKey (KeyframeUtil.GetNew (time, valueRBB, tangentMode));
                            curveRBA.AddKey (KeyframeUtil.GetNew (time, rateRB, tangentMode));
                            curveLTR.AddKey (KeyframeUtil.GetNew (time, valueLTR, tangentMode));
                            curveLTG.AddKey (KeyframeUtil.GetNew (time, valueLTG, tangentMode));
                            curveLTB.AddKey (KeyframeUtil.GetNew (time, valueLTB, tangentMode));
                            curveLTA.AddKey (KeyframeUtil.GetNew (time, rateLT, tangentMode));
                            curveRTR.AddKey (KeyframeUtil.GetNew (time, valueRTR, tangentMode));
                            curveRTG.AddKey (KeyframeUtil.GetNew (time, valueRTG, tangentMode));
                            curveRTB.AddKey (KeyframeUtil.GetNew (time, valueRTB, tangentMode));
                            curveRTA.AddKey (KeyframeUtil.GetNew (time, rateRT, tangentMode));

                            curveRateLB.AddKey (KeyframeUtil.GetNew (time, valueLBA, tangentMode));
                            curveRateRB.AddKey (KeyframeUtil.GetNew (time, valueRBA, tangentMode));
                            curveRateLT.AddKey (KeyframeUtil.GetNew (time, valueLTA, tangentMode));
                            curveRateRT.AddKey (KeyframeUtil.GetNew (time, valueRTA, tangentMode));
                        }

                        clip.SetCurve (part.path, typeof(SSPart), "uv2Y", curveBlend);
                        clip.SetCurve (part.path, typeof(SSPart), "vcolLB.r", curveLBR);
                        clip.SetCurve (part.path, typeof(SSPart), "vcolLB.g", curveLBG);
                        clip.SetCurve (part.path, typeof(SSPart), "vcolLB.b", curveLBB);
                        clip.SetCurve (part.path, typeof(SSPart), "vcolLB.a", curveLBA);
                        clip.SetCurve (part.path, typeof(SSPart), "vcolRB.r", curveRBR);
                        clip.SetCurve (part.path, typeof(SSPart), "vcolRB.g", curveRBG);
                        clip.SetCurve (part.path, typeof(SSPart), "vcolRB.b", curveRBB);
                        clip.SetCurve (part.path, typeof(SSPart), "vcolRB.a", curveRBA);
                        clip.SetCurve (part.path, typeof(SSPart), "vcolLT.r", curveLTR);
                        clip.SetCurve (part.path, typeof(SSPart), "vcolLT.g", curveLTG);
                        clip.SetCurve (part.path, typeof(SSPart), "vcolLT.b", curveLTB);
                        clip.SetCurve (part.path, typeof(SSPart), "vcolLT.a", curveLTA);
                        clip.SetCurve (part.path, typeof(SSPart), "vcolRT.r", curveRTR);
                        clip.SetCurve (part.path, typeof(SSPart), "vcolRT.g", curveRTG);
                        clip.SetCurve (part.path, typeof(SSPart), "vcolRT.b", curveRTB);
                        clip.SetCurve (part.path, typeof(SSPart), "vcolRT.a", curveRTA);
                        clip.SetCurve (part.path, typeof(SSPart), "uv2XLB", curveRateLB);
                        clip.SetCurve (part.path, typeof(SSPart), "uv2XRB", curveRateRB);
                        clip.SetCurve (part.path, typeof(SSPart), "uv2XLT", curveRateLT);
                        clip.SetCurve (part.path, typeof(SSPart), "uv2XRT", curveRateRT);
                    }
                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "VERT");
                    if (attribute != null) {
                        AnimationCurve curveLBX = new AnimationCurve ();
                        AnimationCurve curveLBY = new AnimationCurve ();
                        AnimationCurve curveRBX = new AnimationCurve ();
                        AnimationCurve curveRBY = new AnimationCurve ();
                        AnimationCurve curveLTX = new AnimationCurve ();
                        AnimationCurve curveLTY = new AnimationCurve ();
                        AnimationCurve curveRTX = new AnimationCurve ();
                        AnimationCurve curveRTY = new AnimationCurve ();
                        for (int i = 0; i < attribute.key.Length; i++) {
                            SpriteStudioAnimePackAnimePartAnimeAttributeKey key = attribute.key [i];
                            float time = GetTime (key.time, clip.frameRate);
                            Vector2 vertexLB = GetVector2 (key.value.LB.Text [0]);
                            Vector2 vertexRB = GetVector2 (key.value.RB.Text [0]);
                            Vector2 vertexLT = GetVector2 (key.value.LT.Text [0]);
                            Vector2 vertexRT = GetVector2 (key.value.RT.Text [0]);
                            curveLBX.AddKey (KeyframeUtil.GetNew (time, vertexLB.x, tangentMode));
                            curveLBY.AddKey (KeyframeUtil.GetNew (time, vertexLB.y, tangentMode));
                            curveRBX.AddKey (KeyframeUtil.GetNew (time, vertexRB.x, tangentMode));
                            curveRBY.AddKey (KeyframeUtil.GetNew (time, vertexRB.y, tangentMode));
                            curveLTX.AddKey (KeyframeUtil.GetNew (time, vertexLT.x, tangentMode));
                            curveLTY.AddKey (KeyframeUtil.GetNew (time, vertexLT.y, tangentMode));
                            curveRTX.AddKey (KeyframeUtil.GetNew (time, vertexRT.x, tangentMode));
                            curveRTY.AddKey (KeyframeUtil.GetNew (time, vertexRT.y, tangentMode));
                        }
                        clip.SetCurve (part.path, typeof(SSPart), "vertLB.x", curveLBX);
                        clip.SetCurve (part.path, typeof(SSPart), "vertLB.y", curveLBY);
                        clip.SetCurve (part.path, typeof(SSPart), "vertRB.x", curveRBX);
                        clip.SetCurve (part.path, typeof(SSPart), "vertRB.y", curveRBY);
                        clip.SetCurve (part.path, typeof(SSPart), "vertLT.x", curveLTX);
                        clip.SetCurve (part.path, typeof(SSPart), "vertLT.y", curveLTY);
                        clip.SetCurve (part.path, typeof(SSPart), "vertRT.x", curveRTX);
                        clip.SetCurve (part.path, typeof(SSPart), "vertRT.y", curveRTY);
                    }

            //					attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "BNDR");
            //					if (attribute != null) {
            //						AnimationCurve curve = new AnimationCurve ();
            //						SetFloatCurve (curve, attribute, clip.frameRate, frameCount);
            //						CircleCollider2D collider = part.GetComponent<CircleCollider2D> ();
            //						if (collider == null) {
            //							collider = part.gameObject.AddComponent<CircleCollider2D> ();
            //							collider.enabled = false;
            //						}
            //						clip.SetCurve (part.path, typeof(CircleCollider2D), "radius", curve);
            //					}

                    attribute = partAnime.attributes.SingleOrDefault (v => v.tag == "USER");
                    if (attribute != null) {
                        List<AnimationEvent> eventList = new List<AnimationEvent> ();
                        for (int i = 0; i < attribute.key.Length; i++) {
                            SpriteStudioAnimePackAnimePartAnimeAttributeKey key = attribute.key [i];
                            float time = GetTime (key.time, clip.frameRate);

                            if (key.value.integerSpecified) {
                                AnimationEvent animationEvent = new AnimationEvent ();
                                animationEvent.time = time;
                                animationEvent.functionName = "IntegerEvent";
                                animationEvent.intParameter = key.value.integer;
                                eventList.Add (animationEvent);
                            }
                            if (key.value.rect != null) {
                                AnimationEvent animationEvent = new AnimationEvent ();
                                animationEvent.time = time;
                                animationEvent.functionName = "RectEvent";
                                animationEvent.stringParameter = key.value.rect;
                                eventList.Add (animationEvent);
                            }
                            if (key.value.point != null) {
                                AnimationEvent animationEvent = new AnimationEvent ();
                                animationEvent.time = time;
                                animationEvent.functionName = "PointEvent";
                                animationEvent.stringParameter = key.value.point;
                                eventList.Add (animationEvent);
                            }
                            if (key.value.@string != null) {
                                AnimationEvent animationEvent = new AnimationEvent ();
                                animationEvent.time = time;
                                animationEvent.functionName = "StringEvent";
                                animationEvent.stringParameter = key.value.@string;
                                eventList.Add (animationEvent);
                            }
                        }
                        AnimationUtility.SetAnimationEvents (clip, eventList.ToArray ());
                    }
                }
            }

            controllerObj.transform.localScale = new Vector3 (1.0f / pixelPerUnit, 1.0f / pixelPerUnit, 1.0f / pixelPerUnit);
            string prefabPath = prefabsDirectory + "/" + controllerObj.name + ".prefab";
            PrefabUtility.CreatePrefab (prefabPath, controllerObj);

            UnityEngine.GameObject.DestroyImmediate (controllerObj);
            AssetDatabase.SaveAssets ();
            AssetDatabase.Refresh ();
        }

Usage Example

        bool CreateAnimations(SpriteStudioBaker baker)
        {
            string message = null;

            if (baker.animePackList == null)
                return true;

            try
            {
                for (int i = 0; i < baker.animePackList.Count; i++)
                {
                    SpriteStudioAnimePack animePack = baker.animePackList [i];
                    message = animePack.name;
                    EditorUtility.DisplayProgressBar("Sprite Studio For Unity", "Create Animator(" + (i + 1) + "/" + baker.animePackList.Count + ") : " + animePack.name, 0.9f);
                    baker.CreateAnimator(animePack);
                }
            } catch (Exception e)
            {
                EditorUtility.DisplayDialog("Error", "Create Animator : " + message, "OK");
                Debug.Log(e.StackTrace);
                return false;
            }
            return true;
        }