public void _SwitchScene(string sceneName)
    {
        effectCamera.depth = 10;
        effectAnimator.Play("switch_scene");
        Debug.Log("In _SwitchScene");
        // Find clip
        AnimationClip clip = null;

        foreach (var c in effectAnimator.runtimeAnimatorController.animationClips)
        {
            if (c.name == "switch_scene")
            {
                clip = c;
                break;
            }
        }

        var evt = new UnityEngine.AnimationEvent();

        evt.stringParameter          = sceneName;
        evt.objectReferenceParameter = clip;
        evt.time         = 0.83f;
        evt.functionName = "__SwitchScene";

        Debug.Log(clip);
        clip.AddEvent(evt);
    }
Ejemplo n.º 2
0
        private void Func(string strParam, UnityEngine.AnimationEvent eventParam)
        {
            var    paramArr  = strParam.Split('|');
            var    className = paramArr[0];
            string param     = null;

            if (paramArr.Length > 1)
            {
                param = paramArr[1];
            }
            if (_eventCallbacks.ContainsKey(className))
            {
                EventParams.Add(new KeyValuePair <short, string>(_classNameToEventId[className], param));
                _eventCallbacks[className].AnimationEventCallback(Player, param, eventParam);
            }
            else
            {
                _logger.ErrorFormat("Class {0} not exist", className);
            }
//            Type t = Type.GetType(NameSpace + "." + className);
//            if (null == t)
//            {
//                _logger.ErrorFormat("Class {0} not exist", className);
//                return;
//            }
//            // 构造
//            object[] constructParams = new object[] { };
//            object obj = Activator.CreateInstance(t, constructParams);
//            // 找到method
//            MethodInfo method = t.GetMethod(_methodName);
//            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance;
//            object[] parameters = new object[] { Player, param };
//            // 执行回调
//            object returnValue = method.Invoke(obj, flag, Type.DefaultBinder, parameters, null);
        }
    static void AnimationEvent_isFiredByAnimator(JSVCall vc)
    {
        UnityEngine.AnimationEvent _this = (UnityEngine.AnimationEvent)vc.csObj;
        var result = _this.isFiredByAnimator;

        JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
    }
 static void AnimationClip_events(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.AnimationClip _this = (UnityEngine.AnimationClip)vc.csObj;
         var result = _this.events;
         var arrRet = result;
         for (int i = 0; arrRet != null && i < arrRet.Length; i++)
         {
             JSMgr.datax.setObject((int)JSApi.SetType.SaveAndTempTrace, arrRet[i]);
             JSApi.moveSaveID2Arr(i);
         }
         JSApi.setArrayS((int)JSApi.SetType.Rval, (arrRet != null ? arrRet.Length : 0), true);
     }
     else
     {
         UnityEngine.AnimationEvent[] arg0 = JSDataExchangeMgr.GetJSArg <UnityEngine.AnimationEvent[]>(() =>
         {
             int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg);
             int length  = JSApi.getArrayLength(jsObjID);
             var ret     = new UnityEngine.AnimationEvent[length];
             for (var i = 0; i < length; i++)
             {
                 JSApi.getElement(jsObjID, i);
                 ret[i] = (UnityEngine.AnimationEvent)JSMgr.datax.getObject((int)JSApi.GetType.SaveAndRemove);
             }
             return(ret);
         });
         UnityEngine.AnimationClip _this = (UnityEngine.AnimationClip)vc.csObj;
         _this.events = arg0;
     }
 }
 private void CheckRectsOnMouseMove(Rect eventLineRect, AnimationEvent[] events, Rect[] hitRects)
 {
     Vector2 mousePosition = Event.current.mousePosition;
     bool flag = false;
     this.m_InstantTooltipText = string.Empty;
     if (events.Length == hitRects.Length)
     {
         for (int i = hitRects.Length - 1; i >= 0; i--)
         {
             if (hitRects[i].Contains(mousePosition))
             {
                 flag = true;
                 if (this.m_HoverEvent != i)
                 {
                     this.m_HoverEvent = i;
                     this.m_InstantTooltipText = events[this.m_HoverEvent].functionName;
                     this.m_InstantTooltipPoint = new Vector2(mousePosition.x, mousePosition.y);
                 }
             }
         }
     }
     if (!flag)
     {
         this.m_HoverEvent = -1;
     }
 }
 private void CheckRectsOnMouseMove(Rect eventLineRect, AnimationEvent[] events, Rect[] hitRects)
 {
     Vector2 mousePosition = Event.current.mousePosition;
     bool flag = false;
     if (events.Length == hitRects.Length)
     {
         for (int i = hitRects.Length - 1; i >= 0; i--)
         {
             if (hitRects[i].Contains(mousePosition))
             {
                 flag = true;
                 if (this.m_HoverEvent != i)
                 {
                     this.m_HoverEvent = i;
                     this.m_InstantTooltipText = events[this.m_HoverEvent].functionName;
                     this.m_InstantTooltipPoint = new Vector2((hitRects[this.m_HoverEvent].xMin + ((int) (hitRects[this.m_HoverEvent].width / 2f))) + eventLineRect.x, eventLineRect.yMax);
                     this.m_DirtyTooltip = true;
                 }
             }
         }
     }
     if (!flag)
     {
         this.m_HoverEvent = -1;
         this.m_InstantTooltipText = "";
     }
 }
 static public int constructor(IntPtr l)
 {
     UnityEngine.AnimationEvent o;
     o = new UnityEngine.AnimationEvent();
     pushObject(l, o);
     return(1);
 }
Ejemplo n.º 8
0
    static void AnimationEvent_animationState(JSVCall vc)
    {
        UnityEngine.AnimationEvent _this = (UnityEngine.AnimationEvent)vc.csObj;
        var result = _this.animationState;

        JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
    }
Ejemplo n.º 9
0
        public void InterruptAnimationEventFunc(UnityEngine.AnimationEvent eventParam)
        {
            string strParam = eventParam.stringParameter;
            var    paramArr = strParam.Split('_');

            Func(paramArr[0], eventParam);
        }
 static public int set_objectReferenceParameter(IntPtr l)
 {
     UnityEngine.AnimationEvent o = (UnityEngine.AnimationEvent)checkSelf(l);
     UnityEngine.Object         v;
     checkType(l, 2, out v);
     o.objectReferenceParameter = v;
     return(0);
 }
 static public int set_messageOptions(IntPtr l)
 {
     UnityEngine.AnimationEvent     o = (UnityEngine.AnimationEvent)checkSelf(l);
     UnityEngine.SendMessageOptions v;
     checkEnum(l, 2, out v);
     o.messageOptions = v;
     return(0);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// <para>Adds an animation event to the clip.</para>
 /// </summary>
 /// <param name="evt">AnimationEvent to add.</param>
 public void AddEvent(AnimationEvent evt)
 {
     if (evt == null)
     {
         throw new ArgumentNullException("evt");
     }
     this.AddEventInternal(evt);
 }
Ejemplo n.º 13
0
 public void AnimationEventCallback(PlayerEntity player, string param, UnityEngine.AnimationEvent eventParam)
 {
     //    if (lastFrameCount == Time.frameCount)
     //        return;
     //    lastFrameCount = Time.frameCount;
     ////    DebugUtil.MyLog("Jump Up");
     //    if(player.AudioController() != null)
     //        player.AudioController().PlayJumpStepAudio();
 }
Ejemplo n.º 14
0
 protected virtual bool Filter(PlayerEntity player, string param, UnityEngine.AnimationEvent eventParam)
 {
     if (SharedConfig.IsServer || lastFrameCount == Time.frameCount ||
         eventParam.animatorClipInfo.weight <= 0.5f)
     {
         return(false);
     }
     return(true);
 }
    static public int set_intParameter(IntPtr l)
    {
        UnityEngine.AnimationEvent o = (UnityEngine.AnimationEvent)checkSelf(l);
        int v;

        checkType(l, 2, out v);
        o.intParameter = v;
        return(0);
    }
    static public int set_functionName(IntPtr l)
    {
        UnityEngine.AnimationEvent o = (UnityEngine.AnimationEvent)checkSelf(l);
        string v;

        checkType(l, 2, out v);
        o.functionName = v;
        return(0);
    }
    static public int set_time(IntPtr l)
    {
        UnityEngine.AnimationEvent o = (UnityEngine.AnimationEvent)checkSelf(l);
        float v;

        checkType(l, 2, out v);
        o.time = v;
        return(0);
    }
    public AnimationEvent CreateEvent(AnimationClip clip)
    {
        var evt = new UnityEngine.AnimationEvent()
        {
            functionName = this.functionName, time = this.percent * clip.length
        };

        return(evt);
    }
Ejemplo n.º 19
0
 private void AddEvent(HeroAction action, string functionName, float time)
 {
     if (BattleManager.Instance.InformAnimationClip(thisAnimation.GetClip(action.ToString())))
     {
         UnityEngine.AnimationEvent evt = new UnityEngine.AnimationEvent();
         evt.functionName = functionName;
         evt.time         = time;
         thisAnimation.GetClip(action.ToString()).AddEvent(evt);
     }
 }
 static public int get_messageOptions(IntPtr l)
 {
     try {
         UnityEngine.AnimationEvent self = (UnityEngine.AnimationEvent)checkSelf(l);
         pushEnum(l, (int)self.messageOptions);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_animatorClipInfo(IntPtr l)
 {
     try {
         UnityEngine.AnimationEvent self = (UnityEngine.AnimationEvent)checkSelf(l);
         pushValue(l, self.animatorClipInfo);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_intParameter(IntPtr l)
 {
     try {
         UnityEngine.AnimationEvent self = (UnityEngine.AnimationEvent)checkSelf(l);
         pushValue(l, self.intParameter);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 23
0
        public UnityEngine.AnimationEvent GetAnimEvent(float total_length)
        {
            UnityEngine.AnimationEvent AnimEvent = new UnityEngine.AnimationEvent();
            AnimEvent.time            = total_length * InjectPosition;
            AnimEvent.functionName    = FunctionName;
            AnimEvent.intParameter    = intParam;
            AnimEvent.stringParameter = stringParam;
            AnimEvent.floatParameter  = floatParam;

            return(AnimEvent);
        }
Ejemplo n.º 24
0
    public void __SwitchScene(UnityEngine.AnimationEvent evt)
    {
        string sceneName = evt.stringParameter;
        object clip      = evt.objectReferenceParameter;

        Debug.Log("Switching to scene '" + sceneName + "'");
        SceneManager.LoadSceneAsync(sceneName);
        AnimationClip clipReal = clip as AnimationClip;

        RemoveEventByFunctionName(clipReal, "__SwitchScene");
    }
Ejemplo n.º 25
0
 protected override void DoAnimationEvent(PlayerEntity player, UnityEngine.AnimationEvent eventParam)
 {
     if (eventParam.animatorClipInfo.weight > 0.5f || player.StateInteractController().GetCurrStates().Contains(EPlayerState.ProneMove))
     {
         var audioController = player.AudioController();
         audioController.StopSwimAudio();
         AudioGrp_Footstep stepState = player.GetFootStepState();
         audioController.PlayFootstepAudioC(stepState);
         lastFrameCount = Time.frameCount;
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.AnimationEvent o;
         o = new UnityEngine.AnimationEvent();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 27
0
 static public int get_floatParameter(IntPtr l)
 {
     try {
         UnityEngine.AnimationEvent self = (UnityEngine.AnimationEvent)checkSelf(l);
         pushValue(l, self.floatParameter);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.AnimationEvent o;
			o=new UnityEngine.AnimationEvent();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
Ejemplo n.º 29
0
 static public int get_isFiredByLegacy(IntPtr l)
 {
     try {
         UnityEngine.AnimationEvent self = (UnityEngine.AnimationEvent)checkSelf(l);
         pushValue(l, self.isFiredByLegacy);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Ejemplo n.º 30
0
 static public int get_animatorStateInfo(IntPtr l)
 {
     try {
         UnityEngine.AnimationEvent self = (UnityEngine.AnimationEvent)checkSelf(l);
         pushValue(l, self.animatorStateInfo);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Ejemplo n.º 31
0
        public void AnimationEventFunc(UnityEngine.AnimationEvent eventParam)
        {
            string strParam = eventParam.stringParameter;
            var    cleanArr = _matcher.Match(strParam);

            if (cleanArr.Equals(_cleanStr))
            {// 复位操作,正常不执行,打断时执行
                return;
            }

            Func(strParam, eventParam);
        }
Ejemplo n.º 32
0
 static public int get_isFiredByAnimator(IntPtr l)
 {
     try {
         UnityEngine.AnimationEvent self = (UnityEngine.AnimationEvent)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.isFiredByAnimator);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
// methods

    static bool AnimationClip_AddEvent__AnimationEvent(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 1)
        {
            UnityEngine.AnimationEvent arg0 = (UnityEngine.AnimationEvent)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            ((UnityEngine.AnimationClip)vc.csObj).AddEvent(arg0);
        }

        return(true);
    }
Ejemplo n.º 34
0
 static public int get_objectReferenceParameter(IntPtr l)
 {
     try {
         UnityEngine.AnimationEvent self = (UnityEngine.AnimationEvent)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.objectReferenceParameter);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.AnimationEvent o;
         o=new UnityEngine.AnimationEvent();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
 public static AnimationWindowEvent CreateAndEdit(GameObject root, AnimationClip clip, float time)
 {
     AnimationEvent evt = new AnimationEvent {
         time = time
     };
     int num = InsertAnimationEvent(ref AnimationUtility.GetAnimationEvents(clip), clip, evt);
     AnimationWindowEvent event3 = ScriptableObject.CreateInstance<AnimationWindowEvent>();
     event3.hideFlags = HideFlags.HideInHierarchy;
     event3.name = "Animation Event";
     event3.root = root;
     event3.clip = clip;
     event3.clipInfo = null;
     event3.eventIndex = num;
     return event3;
 }
 private bool DeleteEvents(ref AnimationEvent[] eventList, bool[] deleteIndices)
 {
     bool flag = false;
     for (int i = eventList.Length - 1; i >= 0; i--)
     {
         if (deleteIndices[i])
         {
             ArrayUtility.RemoveAt<AnimationEvent>(ref eventList, i);
             flag = true;
         }
     }
     if (flag)
     {
         this.m_EventsSelected = new bool[eventList.Length];
         this.m_Event = null;
     }
     return flag;
 }
 private static int InsertAnimationEvent(ref AnimationEvent[] events, AnimationClip clip, AnimationEvent evt)
 {
     Undo.RegisterCompleteObjectUndo(clip, "Add Event");
     int length = events.Length;
     for (int i = 0; i < events.Length; i++)
     {
         if (events[i].time > evt.time)
         {
             length = i;
             break;
         }
     }
     ArrayUtility.Insert<AnimationEvent>(ref events, length, evt);
     AnimationUtility.SetAnimationEvents(clip, events);
     events = AnimationUtility.GetAnimationEvents(clip);
     if ((events[length].time != evt.time) || (events[length].functionName != events[length].functionName))
     {
         Debug.LogError("Failed insertion");
     }
     return length;
 }
		/// <summary>
		/// 	Called when an animation event is fired.
		/// </summary>
		/// <param name="animationEvent">Animation event.</param>
		public void OnEventFired(AnimationEvent animationEvent)
		{
			EventHandler<AnimationEventArguments> handler = onAnimationEventCallback;
			if (handler != null)
				handler(this, new AnimationEventArguments(animationEvent));
		}
 public void SetEvents(AnimationEvent[] newEvents)
 {
   SerializedProperty serializedProperty = this.Get("events");
   if (serializedProperty == null || !serializedProperty.isArray)
     return;
   serializedProperty.ClearArray();
   foreach (AnimationEvent newEvent in newEvents)
   {
     serializedProperty.InsertArrayElementAtIndex(serializedProperty.arraySize);
     this.SetEvent(serializedProperty.arraySize - 1, newEvent);
   }
 }
 public void SetEvents(AnimationEvent[] newEvents)
 {
     SerializedProperty property = this.Get("events");
     if ((property != null) && property.isArray)
     {
         property.ClearArray();
         foreach (AnimationEvent event2 in newEvents)
         {
             property.InsertArrayElementAtIndex(property.arraySize);
             this.SetEvent(property.arraySize - 1, event2);
         }
     }
 }
 public AnimationEvent[] GetEvents()
 {
     AnimationEvent[] eventArray = new AnimationEvent[this.GetEventCount()];
     SerializedProperty property = this.Get("events");
     if ((property != null) && property.isArray)
     {
         for (int i = 0; i < this.GetEventCount(); i++)
         {
             eventArray[i] = this.GetEvent(i);
         }
     }
     return eventArray;
 }
		private static bool IsLogicGraphEvent(AnimationEvent evt)
		{
			return evt.functionName == "LogicGraphEvent";
		}
Ejemplo n.º 44
0
 public static extern void SetAnimationEvents(AnimationClip clip, AnimationEvent[] events);
Ejemplo n.º 45
0
 /// <summary>
 ///   <para>Adds an animation event to the clip.</para>
 /// </summary>
 /// <param name="evt">AnimationEvent to add.</param>
 public void AddEvent(AnimationEvent evt)
 {
   this.AddEventInternal((object) evt);
 }
        public bool HandleEventManipulation(Rect rect, ref AnimationEvent[] events, AnimationClipInfoProperties clipInfo)
        {
            int num8;
            float num9;
            float num10;
            Texture image = EditorGUIUtility.IconContent("Animation.EventMarker").image;
            bool flag = false;
            Rect[] hitPositions = new Rect[events.Length];
            Rect[] positions = new Rect[events.Length];
            int num = 1;
            int num2 = 0;
            for (int i = 0; i < events.Length; i++)
            {
                AnimationEvent event2 = events[i];
                if (num2 == 0)
                {
                    num = 1;
                    while (((i + num) < events.Length) && (events[i + num].time == event2.time))
                    {
                        num++;
                    }
                    num2 = num;
                }
                num2--;
                float num4 = Mathf.Floor(this.m_Timeline.TimeToPixel(event2.time, rect));
                int num5 = 0;
                if (num > 1)
                {
                    float num6 = Mathf.Min((int) ((num - 1) * (image.width - 1)), (int) (((int) (1f / this.m_Timeline.PixelDeltaToTime(rect))) - (image.width * 2)));
                    num5 = Mathf.FloorToInt(Mathf.Max((float) 0f, (float) (num6 - ((image.width - 1) * num2))));
                }
                Rect rect2 = new Rect((num4 + num5) - (image.width / 2), ((rect.height - 10f) * ((num2 - num) + 1)) / ((float) Mathf.Max(1, num - 1)), (float) image.width, (float) image.height);
                hitPositions[i] = rect2;
                positions[i] = rect2;
            }
            this.m_EventRects = new Rect[hitPositions.Length];
            for (int j = 0; j < hitPositions.Length; j++)
            {
                this.m_EventRects[j] = new Rect(hitPositions[j].x + rect.x, hitPositions[j].y + rect.y, hitPositions[j].width, hitPositions[j].height);
            }
            if (((this.m_EventsSelected == null) || (this.m_EventsSelected.Length != events.Length)) || (this.m_EventsSelected.Length == 0))
            {
                this.m_EventsSelected = new bool[events.Length];
                this.m_Event = null;
            }
            Vector2 zero = Vector2.zero;
            switch (EditorGUIExt.MultiSelection(rect, positions, new GUIContent(image), hitPositions, ref this.m_EventsSelected, null, out num8, out zero, out num9, out num10, GUIStyle.none))
            {
                case HighLevelEvent.ContextClick:
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), new EventModificationContextMenuObjet(clipInfo, events[num8].time, num8));
                    menu.AddItem(new GUIContent("Delete Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), new EventModificationContextMenuObjet(clipInfo, events[num8].time, num8));
                    menu.ShowAsContext();
                    this.m_InstantTooltipText = null;
                    break;
                }
                case HighLevelEvent.BeginDrag:
                    m_EventsAtMouseDown = events;
                    m_EventTimes = new float[events.Length];
                    for (int k = 0; k < events.Length; k++)
                    {
                        m_EventTimes[k] = events[k].time;
                    }
                    break;

                case HighLevelEvent.Drag:
                {
                    for (int m = events.Length - 1; m >= 0; m--)
                    {
                        if (this.m_EventsSelected[m])
                        {
                            AnimationEvent event4 = m_EventsAtMouseDown[m];
                            event4.time = Mathf.Clamp01(m_EventTimes[m] + (zero.x / rect.width));
                        }
                    }
                    int[] items = new int[this.m_EventsSelected.Length];
                    for (int n = 0; n < items.Length; n++)
                    {
                        items[n] = n;
                    }
                    Array.Sort(m_EventsAtMouseDown, items, new AnimationEventTimeLine.EventComparer());
                    bool[] flagArray = (bool[]) this.m_EventsSelected.Clone();
                    float[] numArray2 = (float[]) m_EventTimes.Clone();
                    for (int num14 = 0; num14 < items.Length; num14++)
                    {
                        this.m_EventsSelected[num14] = flagArray[items[num14]];
                        m_EventTimes[num14] = numArray2[items[num14]];
                    }
                    events = m_EventsAtMouseDown;
                    flag = true;
                    break;
                }
                case HighLevelEvent.Delete:
                    flag = this.DeleteEvents(ref events, this.m_EventsSelected);
                    break;

                case HighLevelEvent.SelectionChanged:
                    this.m_Event = (num8 < 0) ? null : AnimationWindowEvent.Edit(clipInfo, num8);
                    break;
            }
            this.CheckRectsOnMouseMove(rect, events, hitPositions);
            return flag;
        }
        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 ();
        }
		/// <summary>
		/// 	Initializes a new instance of the
		/// 	<see cref="Hydra.HydraCommon.EventArguments.AnimationEventArguments"/> class.
		/// </summary>
		/// <param name="animationEvent">Animation event.</param>
		public AnimationEventArguments(AnimationEvent animationEvent)
		{
			m_AnimationEvent = animationEvent;
		}
Ejemplo n.º 49
0
		static void ParseEventTimeline (EventTimeline timeline, AnimationClip clip, SendMessageOptions eventOptions) {

			float[] frames = timeline.Frames;
			var events = timeline.Events;

			List<AnimationEvent> animEvents = new List<AnimationEvent>();
			for (int i = 0; i < frames.Length; i++) {
				var ev = events[i];

				AnimationEvent ae = new AnimationEvent();
				//MITCH: left todo:  Deal with Mecanim's zero-time missed event
				ae.time = frames[i];
				ae.functionName = ev.Data.Name;
				ae.messageOptions = eventOptions;

				if (!string.IsNullOrEmpty(ev.String)) {
					ae.stringParameter = ev.String;
				} else {
					if (ev.Int == 0 && ev.Float == 0) {
						//do nothing, raw function
					} else {
						if (ev.Int != 0)
							ae.floatParameter = (float)ev.Int;
						else
							ae.floatParameter = ev.Float;
					}

				}

				animEvents.Add(ae);
			}

			AnimationUtility.SetAnimationEvents(clip, animEvents.ToArray());
		}
		internal static int Create(GameObject root, AnimationClip clip, float time, EditorWindow owner)
		{
			AnimationEvent animationEvent = new AnimationEvent();
			animationEvent.time = time;
			AnimationEvent[] animationEvents = AnimationUtility.GetAnimationEvents(clip);
			int num = AnimationEventPopup.InsertAnimationEvent(ref animationEvents, clip, animationEvent);
			AnimationEventPopup window = EditorWindow.GetWindow<AnimationEventPopup>(true);
			AnimationEventPopup.InitWindow(window);
			window.m_Root = root;
			window.m_Clip = clip;
			window.eventIndex = num;
			window.m_Owner = owner;
			return num;
		}
 public AnimationEvent GetEvent(int index)
 {
     AnimationEvent event2 = new AnimationEvent();
     SerializedProperty property = this.Get("events");
     if ((property != null) && property.isArray)
     {
         if (index < property.arraySize)
         {
             event2.floatParameter = property.GetArrayElementAtIndex(index).FindPropertyRelative("floatParameter").floatValue;
             event2.functionName = property.GetArrayElementAtIndex(index).FindPropertyRelative("functionName").stringValue;
             event2.intParameter = property.GetArrayElementAtIndex(index).FindPropertyRelative("intParameter").intValue;
             event2.objectReferenceParameter = property.GetArrayElementAtIndex(index).FindPropertyRelative("objectReferenceParameter").objectReferenceValue;
             event2.stringParameter = property.GetArrayElementAtIndex(index).FindPropertyRelative("data").stringValue;
             event2.time = property.GetArrayElementAtIndex(index).FindPropertyRelative("time").floatValue;
             return event2;
         }
         Debug.LogWarning("Invalid Event Index");
     }
     return event2;
 }
Ejemplo n.º 52
0
        static void AddEvents(	AnimationClip           clip,
								List< JsonData >		events, 
								string					animName  )
        {
            List< UnityEngine.AnimationEvent > unityEvents = new List<UnityEngine.AnimationEvent>( );
            foreach ( JsonData entry in events ) {
                if ( !entry.IsObject )
                    Debug.LogError( "JSON data is wrong. Event is not an Object??!!" );
                IDictionary entry_dict = entry as IDictionary;

                UnityEngine.AnimationEvent ev = new UnityEngine.AnimationEvent( );

                if ( entry_dict.Contains( "name" ) )
                    ev.functionName = ( ( string ) entry[ "name" ] );
                else
                    Debug.LogError( "JSON data is wrong. Missing Name in event data: " + animName );

                if ( entry_dict.Contains( "time" ) )
                    ev.time = getNumberData( entry[ "time" ], animName );
                else
                    Debug.LogError( "JSON data is wrong. Missing Time in event data: " + animName + " EVENT_NAME: " + ev.functionName );

                bool ParamAdded = false;
                if ( entry_dict.Contains( "int" ) ) {
                    ev.intParameter = ( int ) entry[ "int" ];
                    ParamAdded = true;
                }

                if ( entry_dict.Contains( "float" ) ) {
                    if ( ParamAdded )
                        Debug.LogError( "JSON data is wrong. Unity Supports only one event parameter!!!! CLIP NAME: " + animName + " EVENT_NAME: " + entry.ToJson( ) );
                    ev.floatParameter = getNumberData( entry[ "float" ], animName );
                    ParamAdded = true;
                }

                if ( entry_dict.Contains( "string" ) ) {
                    if ( ParamAdded )
                        Debug.LogError( "JSON data is wrong. Unity Supports only one event parameter!!!! CLIP NAME: " + animName + " EVENT_NAME: " + entry.ToJson( ) );
                    ev.stringParameter = ( string ) entry[ "string" ];
                }

                ev.messageOptions = SendMessageOptions.RequireReceiver;

                unityEvents.Add( ev );
            }

            AnimationUtility.SetAnimationEvents( clip, unityEvents.ToArray( ) );
        }
 public void SetEvent(int index, AnimationEvent animationEvent)
 {
     SerializedProperty property = this.Get("events");
     if ((property != null) && property.isArray)
     {
         if (index < property.arraySize)
         {
             property.GetArrayElementAtIndex(index).FindPropertyRelative("floatParameter").floatValue = animationEvent.floatParameter;
             property.GetArrayElementAtIndex(index).FindPropertyRelative("functionName").stringValue = animationEvent.functionName;
             property.GetArrayElementAtIndex(index).FindPropertyRelative("intParameter").intValue = animationEvent.intParameter;
             property.GetArrayElementAtIndex(index).FindPropertyRelative("objectReferenceParameter").objectReferenceValue = animationEvent.objectReferenceParameter;
             property.GetArrayElementAtIndex(index).FindPropertyRelative("data").stringValue = animationEvent.stringParameter;
             property.GetArrayElementAtIndex(index).FindPropertyRelative("time").floatValue = animationEvent.time;
         }
         else
         {
             Debug.LogWarning("Invalid Event Index");
         }
     }
 }
 private bool DeleteEvents(ref AnimationEvent[] eventList, bool[] deleteIndices)
 {
   bool flag = false;
   for (int index = eventList.Length - 1; index >= 0; --index)
   {
     if (deleteIndices[index])
     {
       ArrayUtility.RemoveAt<AnimationEvent>(ref eventList, index);
       flag = true;
     }
   }
   if (flag)
   {
     AnimationEventPopup.ClosePopup();
     this.m_EventsSelected = new bool[eventList.Length];
   }
   return flag;
 }
 public void SelectEvent(AnimationEvent[] events, int index, AnimationClipInfoProperties clipInfo)
 {
   this.m_EventsSelected = new bool[events.Length];
   this.m_EventsSelected[index] = true;
   AnimationEventPopup.Edit(clipInfo, index);
 }
 public bool HandleEventManipulation(Rect rect, ref AnimationEvent[] events, AnimationClipInfoProperties clipInfo)
 {
   Texture image = EditorGUIUtility.IconContent("Animation.EventMarker").image;
   bool flag = false;
   Rect[] rectArray = new Rect[events.Length];
   Rect[] positions = new Rect[events.Length];
   int num1 = 1;
   int num2 = 0;
   for (int index = 0; index < events.Length; ++index)
   {
     AnimationEvent animationEvent = events[index];
     if (num2 == 0)
     {
       num1 = 1;
       while (index + num1 < events.Length && (double) events[index + num1].time == (double) animationEvent.time)
         ++num1;
       num2 = num1;
     }
     --num2;
     float num3 = Mathf.Floor(this.m_Timeline.TimeToPixel(animationEvent.time, rect));
     int num4 = 0;
     if (num1 > 1)
       num4 = Mathf.FloorToInt(Mathf.Max(0.0f, (float) Mathf.Min((num1 - 1) * (image.width - 1), (int) (1.0 / (double) this.m_Timeline.PixelDeltaToTime(rect) - (double) (image.width * 2))) - (float) ((image.width - 1) * num2)));
     Rect rect1 = new Rect(num3 + (float) num4 - (float) (image.width / 2), (rect.height - 10f) * (float) (num2 - num1 + 1) / (float) Mathf.Max(1, num1 - 1), (float) image.width, (float) image.height);
     rectArray[index] = rect1;
     positions[index] = rect1;
   }
   this.m_EventRects = new Rect[rectArray.Length];
   for (int index = 0; index < rectArray.Length; ++index)
     this.m_EventRects[index] = new Rect(rectArray[index].x + rect.x, rectArray[index].y + rect.y, rectArray[index].width, rectArray[index].height);
   if (this.m_EventsSelected == null || this.m_EventsSelected.Length != events.Length || this.m_EventsSelected.Length == 0)
   {
     this.m_EventsSelected = new bool[events.Length];
     AnimationEventPopup.ClosePopup();
   }
   Vector2 offset = Vector2.zero;
   int clickedIndex;
   float startSelect;
   float endSelect;
   switch (EditorGUIExt.MultiSelection(rect, positions, new GUIContent(image), rectArray, ref this.m_EventsSelected, (bool[]) null, out clickedIndex, out offset, out startSelect, out endSelect, GUIStyle.none))
   {
     case HighLevelEvent.ContextClick:
       GenericMenu genericMenu = new GenericMenu();
       genericMenu.AddItem(new GUIContent("Add Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuAdd), (object) new EventManipulationHandler.EventModificationContextMenuObjet(clipInfo, events[clickedIndex].time, clickedIndex));
       genericMenu.AddItem(new GUIContent("Delete Animation Event"), false, new GenericMenu.MenuFunction2(this.EventLineContextMenuDelete), (object) new EventManipulationHandler.EventModificationContextMenuObjet(clipInfo, events[clickedIndex].time, clickedIndex));
       genericMenu.ShowAsContext();
       this.m_InstantTooltipText = (string) null;
       break;
     case HighLevelEvent.BeginDrag:
       EventManipulationHandler.m_EventsAtMouseDown = events;
       EventManipulationHandler.m_EventTimes = new float[events.Length];
       for (int index = 0; index < events.Length; ++index)
         EventManipulationHandler.m_EventTimes[index] = events[index].time;
       break;
     case HighLevelEvent.Drag:
       for (int index = events.Length - 1; index >= 0; --index)
       {
         if (this.m_EventsSelected[index])
           EventManipulationHandler.m_EventsAtMouseDown[index].time = Mathf.Clamp01(EventManipulationHandler.m_EventTimes[index] + offset.x / rect.width);
       }
       int[] numArray1 = new int[this.m_EventsSelected.Length];
       for (int index = 0; index < numArray1.Length; ++index)
         numArray1[index] = index;
       Array.Sort((Array) EventManipulationHandler.m_EventsAtMouseDown, (Array) numArray1, (IComparer) new AnimationEventTimeLine.EventComparer());
       bool[] flagArray = (bool[]) this.m_EventsSelected.Clone();
       float[] numArray2 = (float[]) EventManipulationHandler.m_EventTimes.Clone();
       for (int index = 0; index < numArray1.Length; ++index)
       {
         this.m_EventsSelected[index] = flagArray[numArray1[index]];
         EventManipulationHandler.m_EventTimes[index] = numArray2[numArray1[index]];
       }
       events = EventManipulationHandler.m_EventsAtMouseDown;
       flag = true;
       break;
     case HighLevelEvent.Delete:
       flag = this.DeleteEvents(ref events, this.m_EventsSelected);
       break;
     case HighLevelEvent.SelectionChanged:
       if (clickedIndex >= 0)
       {
         AnimationEventPopup.Edit(clipInfo, clickedIndex);
         break;
       }
       AnimationEventPopup.ClosePopup();
       break;
   }
   this.CheckRectsOnMouseMove(rect, events, rectArray);
   return flag;
 }
 public AnimationEvent GetEvent(int index)
 {
   AnimationEvent animationEvent = new AnimationEvent();
   SerializedProperty serializedProperty = this.Get("events");
   if (serializedProperty != null && serializedProperty.isArray)
   {
     if (index < serializedProperty.arraySize)
     {
       animationEvent.floatParameter = serializedProperty.GetArrayElementAtIndex(index).FindPropertyRelative("floatParameter").floatValue;
       animationEvent.functionName = serializedProperty.GetArrayElementAtIndex(index).FindPropertyRelative("functionName").stringValue;
       animationEvent.intParameter = serializedProperty.GetArrayElementAtIndex(index).FindPropertyRelative("intParameter").intValue;
       animationEvent.objectReferenceParameter = serializedProperty.GetArrayElementAtIndex(index).FindPropertyRelative("objectReferenceParameter").objectReferenceValue;
       animationEvent.stringParameter = serializedProperty.GetArrayElementAtIndex(index).FindPropertyRelative("data").stringValue;
       animationEvent.time = serializedProperty.GetArrayElementAtIndex(index).FindPropertyRelative("time").floatValue;
     }
     else
       Debug.LogWarning((object) "Invalid Event Index");
   }
   return animationEvent;
 }
 public AnimationEvent[] GetEvents()
 {
   AnimationEvent[] animationEventArray = new AnimationEvent[this.GetEventCount()];
   SerializedProperty serializedProperty = this.Get("events");
   if (serializedProperty != null && serializedProperty.isArray)
   {
     for (int index = 0; index < this.GetEventCount(); ++index)
       animationEventArray[index] = this.GetEvent(index);
   }
   return animationEventArray;
 }
Ejemplo n.º 59
0
		protected override AnimationClip createAnimationClip(GAFTimelineData _Timeline, GAFSequenceData _Sequence, string _Path)
		{
			var animationClip = new AnimationClip()
			{
				frameRate = 30
				,
				name = _Sequence.name
			};

			var framesCount = _Sequence.endFrame - _Sequence.startFrame + 1;
			var timeInterval = framesCount / animationClip.frameRate / framesCount;

			var time = 0f;
			var events = new AnimationEvent[framesCount];
			for (uint i = _Sequence.startFrame, j = 0; i <= _Sequence.endFrame; i++, j++)
			{
				var animationEvent = new AnimationEvent();
				animationEvent.functionName = i != _Sequence.startFrame ? "updateToFrameAnimator" : "updateToFrameAnimatorWithRefresh";
				animationEvent.intParameter = (int)i;
				animationEvent.time = time;

				events[j] = animationEvent;

				time += timeInterval;
			}

			var serializedObj = new SerializedObject(animationClip);
			var settings = serializedObj.FindProperty("m_AnimationClipSettings");
			var loopTime = settings.FindPropertyRelative("m_LoopTime");

			loopTime.boolValue = true;
			serializedObj.ApplyModifiedProperties();

#if !UNITY_5
			AnimationUtility.SetAnimationType(animationClip, ModelImporterAnimationType.Generic);
#endif
			AnimationUtility.SetAnimationEvents(animationClip, events);

			AssetDatabase.CreateAsset(animationClip, _Path);

			return animationClip;
		}
 public void SetEvent(int index, AnimationEvent animationEvent)
 {
   SerializedProperty serializedProperty = this.Get("events");
   if (serializedProperty == null || !serializedProperty.isArray)
     return;
   if (index < serializedProperty.arraySize)
   {
     serializedProperty.GetArrayElementAtIndex(index).FindPropertyRelative("floatParameter").floatValue = animationEvent.floatParameter;
     serializedProperty.GetArrayElementAtIndex(index).FindPropertyRelative("functionName").stringValue = animationEvent.functionName;
     serializedProperty.GetArrayElementAtIndex(index).FindPropertyRelative("intParameter").intValue = animationEvent.intParameter;
     serializedProperty.GetArrayElementAtIndex(index).FindPropertyRelative("objectReferenceParameter").objectReferenceValue = animationEvent.objectReferenceParameter;
     serializedProperty.GetArrayElementAtIndex(index).FindPropertyRelative("data").stringValue = animationEvent.stringParameter;
     serializedProperty.GetArrayElementAtIndex(index).FindPropertyRelative("time").floatValue = animationEvent.time;
   }
   else
     Debug.LogWarning((object) "Invalid Event Index");
 }