Пример #1
0
    private static void 导出(string strFilePath, ModelImporter modelImporter)
    {
        ModelImporterClipAnimation[] animations = modelImporter.clipAnimations;
        try
        {
            string strModeFileFullPath =
                Application.dataPath.Remove(Application.dataPath.LastIndexOf('/') + 1) + strFilePath;
            string strConfigFileFullPath = strModeFileFullPath.Remove(strModeFileFullPath.LastIndexOf('.')) +
                                           string.Format(".Animation.bac{0}", strExtension);
            using (Stream file = File.Open(strConfigFileFullPath, FileMode.Create))
            {
                using (StreamWriter reader = new StreamWriter(file))
                {
                    if (animations.Length > 0)
                    {
                        //GUILayout.Label("当前动画:", EditorStyles.largeLabel);
                        for (int i = 0; i < animations.Length; i++)
                        {
                            ModelImporterClipAnimation animation = animations[i];
                            reader.WriteLine("{0:000}-{1:000}-{2}-{3}", animation.firstFrame, animation.lastFrame, animation.name, animation.wrapMode);
                        }
                    }
                }
            }
        }
        catch (Exception e)
        {
            Debug.LogError(e);
            return;
        }

        AssetDatabase.Refresh();
    }
        public override bool Equals(object o)
        {
            ModelImporterClipAnimation other = o as ModelImporterClipAnimation;

            return(other != null && takeName == other.takeName && name == other.name && firstFrame == other.firstFrame && lastFrame == other.lastFrame && m_WrapMode == other.m_WrapMode && m_Loop == other.m_Loop &&
                   loopPose == other.loopPose && lockRootRotation == other.lockRootRotation && lockRootHeightY == other.lockRootHeightY && lockRootPositionXZ == other.lockRootPositionXZ &&
                   mirror == other.mirror && maskType == other.maskType && maskSource == other.maskSource && additiveReferencePoseFrame == other.additiveReferencePoseFrame && hasAdditiveReferencePose == other.hasAdditiveReferencePose);
        }
 private ModelImporterClipAnimation SetClipAnimation(string name, int firstFrame, int lastFrame, bool loop)
 {
     ModelImporterClipAnimation mica = new ModelImporterClipAnimation();
     mica.name = name;
     mica.firstFrame = firstFrame;
     mica.lastFrame = lastFrame;
     mica.loop = loop;
     return mica;
 }
Пример #4
0
        public override bool Equals(object o)
        {
            ModelImporterClipAnimation importerClipAnimation = o as ModelImporterClipAnimation;

            if (importerClipAnimation != null && this.takeName == importerClipAnimation.takeName && (this.name == importerClipAnimation.name && (double)this.firstFrame == (double)importerClipAnimation.firstFrame) && ((double)this.lastFrame == (double)importerClipAnimation.lastFrame && this.m_WrapMode == importerClipAnimation.m_WrapMode && (this.m_Loop == importerClipAnimation.m_Loop && this.loopPose == importerClipAnimation.loopPose)) && (this.lockRootRotation == importerClipAnimation.lockRootRotation && this.lockRootHeightY == importerClipAnimation.lockRootHeightY && (this.lockRootPositionXZ == importerClipAnimation.lockRootPositionXZ && this.mirror == importerClipAnimation.mirror) && (this.maskType == importerClipAnimation.maskType && (UnityEngine.Object) this.maskSource == (UnityEngine.Object)importerClipAnimation.maskSource && (double)this.additiveReferencePoseFrame == (double)importerClipAnimation.additiveReferencePoseFrame)))
            {
                return(this.hasAdditiveReferencePose == importerClipAnimation.hasAdditiveReferencePose);
            }
            return(false);
        }
Пример #5
0
 /// <summary>
 /// <para>Creates a mask that matches the model hierarchy, and applies it to the provided ModelImporterClipAnimation.</para>
 /// </summary>
 /// <param name="clip">Clip to which the mask will be applied.</param>
 public void CreateDefaultMaskForClip(ModelImporterClipAnimation clip)
 {
     if (this.defaultClipAnimations.Length > 0)
     {
         AvatarMask mask = new AvatarMask();
         this.defaultClipAnimations[0].ConfigureMaskFromClip(ref mask);
         clip.ConfigureClipFromMask(mask);
         Object.DestroyImmediate(mask);
     }
     else
     {
         Debug.LogError("Cannot create default mask because the current importer doesn't have any animation information");
     }
 }
Пример #6
0
 public void CreateDefaultMaskForClip(ModelImporterClipAnimation clip)
 {
     if (this.defaultClipAnimations.Length > 0)
     {
         AvatarMask avatarMask = new AvatarMask();
         this.defaultClipAnimations[0].ConfigureMaskFromClip(ref avatarMask);
         clip.ConfigureClipFromMask(avatarMask);
         UnityEngine.Object.DestroyImmediate(avatarMask);
     }
     else
     {
         Debug.LogError("Cannot create default mask because the current importer doesn't have any animation information");
     }
 }
    void OnPostprocessGameObjectWithUserProperties(GameObject asset, string[] names, object[] values)
    {
        string[] anim_names = Array.FindAll(names, n => n.EndsWith("_anim") );

        ModelImporter mi = (assetImporter as ModelImporter);
        ModelImporterClipAnimation[] newClip = new ModelImporterClipAnimation[(anim_names.Length)];

        //must guarantee we set split animation to true as default
        mi.splitAnimations = true;

        int animIndex = 0;
        //run through all of the extra properties
        for (int i = 0; i < names.Length; i++) {

            string propertyName = names[i];
            object propertyValue = values[i];

            //check for _anim flag
            if (propertyName.EndsWith ("_anim")) {

                Debug.Log ("Propname: " + propertyName + " value: " + propertyValue);

                Vector4 v = (Vector4)propertyValue;

                //get the name
                string name = getNameString(propertyName);

                newClip[animIndex] = new ModelImporterClipAnimation();
                newClip[animIndex].name = name;
                newClip[animIndex].firstFrame = (int)v[0];
                newClip[animIndex].lastFrame = (int)v[1];
                animIndex++;

            }

        }

        //set ModelImporter.clipAnimations to the newClip array only if anim_names is greater than 0
        if(anim_names.Length > 0)
        {
            mi.clipAnimations = newClip;
        }
    }
    private void OnPreprocessModel()
    {
        if (assetPath.Contains("nameofmodel"))
        {
            ModelImporter modelImporter = assetImporter as ModelImporter;
            modelImporter.splitAnimations = true;
            modelImporter.generateAnimations = ModelImporterGenerateAnimations.InRoot;

            // Set the number of animations here
            int numAnimations = 1;
            ModelImporterClipAnimation[] animations = new ModelImporterClipAnimation[numAnimations];

            animations[0] = SetClipAnimation("walk", 0, 24, true);
            // Add your new animation splits here, simply changing the arguments

            // Assign the clips to the model importer to automagically do your splits
            modelImporter.clipAnimations = animations;
        }
    }
    // Called when you press the "Info" button.
    void OnWizardOtherButton()
    {
        XmlDocument doc = new XmlDocument();

        string path = EditorUtility.OpenFilePanel("Settings", "", "xml");

        doc.Load(path);

        ModelImporter importer = (ModelImporter)ModelImporter.GetAtPath(AssetDatabase.GetAssetPath(AssetObject.GetInstanceID()));

        importer.globalScale = float.Parse(doc.SelectSingleNode("Asset").Attributes["ScaleFactor"].Value);

        List<ModelImporterClipAnimation> Animations = new List<ModelImporterClipAnimation>();

        foreach (XmlNode node in doc.SelectNodes("Asset/Animations/Clip"))
        {

            ModelImporterClipAnimation ClipAnimation = new ModelImporterClipAnimation();

            ClipAnimation.name = node.Attributes["name"].Value.ToString();

            ClipAnimation.firstFrame = (int.Parse(node.Attributes["Start"].Value));

            ClipAnimation.lastFrame = (int.Parse(node.Attributes["End"].Value));

            ClipAnimation.wrapMode = (WrapMode)System.Enum.Parse(typeof(WrapMode), node.Attributes["WarpMode"].Value, true);

            ClipAnimation.loopPose = bool.Parse(node.Attributes["Loop"].Value);

            Animations.Add(ClipAnimation);

        }

        importer.clipAnimations = Animations.ToArray();

        AssetDatabase.WriteImportSettingsIfDirty((AssetDatabase.GetAssetPath(AssetObject.GetInstanceID())));

        AssetDatabase.Refresh();

        helpString = "Imported " + Animations.Count.ToString() + "Animations";
    }
        public override bool Equals(object o)
        {
            ModelImporterClipAnimation modelImporterClipAnimation = o as ModelImporterClipAnimation;

            return(modelImporterClipAnimation != null && this.takeName == modelImporterClipAnimation.takeName && this.name == modelImporterClipAnimation.name && this.firstFrame == modelImporterClipAnimation.firstFrame && this.lastFrame == modelImporterClipAnimation.lastFrame && this.m_WrapMode == modelImporterClipAnimation.m_WrapMode && this.m_Loop == modelImporterClipAnimation.m_Loop && this.loopPose == modelImporterClipAnimation.loopPose && this.lockRootRotation == modelImporterClipAnimation.lockRootRotation && this.lockRootHeightY == modelImporterClipAnimation.lockRootHeightY && this.lockRootPositionXZ == modelImporterClipAnimation.lockRootPositionXZ && this.mirror == modelImporterClipAnimation.mirror && this.maskType == modelImporterClipAnimation.maskType && this.maskSource == modelImporterClipAnimation.maskSource);
        }
Пример #11
0
        public override bool Equals(object o)
        {
            ModelImporterClipAnimation animation = o as ModelImporterClipAnimation;

            return((((((animation != null) && (this.takeName == animation.takeName)) && ((this.name == animation.name) && (this.firstFrame == animation.firstFrame))) && (((this.lastFrame == animation.lastFrame) && (this.m_WrapMode == animation.m_WrapMode)) && ((this.m_Loop == animation.m_Loop) && (this.loopPose == animation.loopPose)))) && ((((this.lockRootRotation == animation.lockRootRotation) && (this.lockRootHeightY == animation.lockRootHeightY)) && ((this.lockRootPositionXZ == animation.lockRootPositionXZ) && (this.mirror == animation.mirror))) && (((this.maskType == animation.maskType) && (this.maskSource == animation.maskSource)) && (this.additiveReferencePoseFrame == animation.additiveReferencePoseFrame)))) && (this.hasAdditiveReferencePose == animation.hasAdditiveReferencePose));
        }
Пример #12
0
	/// <summary>
	/// Imprts the state.
	/// </summary>
	/// <param name="animator">Animator.</param>
	/// <param name="aryClip">Ary clip.</param>
	/// <param name="machine">Machine.</param>
	public static void 		ImprtState(Animator animator, List<string> aryClipPath,
	                               	UnityEditor.Animations.AnimatorStateMachine machine, int nOffsetX, int nOffsetY)
	{
		machine.entryPosition 		= new Vector3(machine.entryPosition.x + nOffsetX, machine.entryPosition.y, 0);
		machine.anyStatePosition	= new Vector3(machine.entryPosition.x, machine.entryPosition.y - nOffsetY, 0);
		machine.exitPosition		= new Vector3(machine.entryPosition.x, machine.entryPosition.y + nOffsetY, 0);
		
		for(int i=0; i<aryClipPath.Count; i++)
		{
			ModelImporter imp = ModelImporter.GetAtPath(aryClipPath[i]) as ModelImporter;
			if (!imp)
				throw new System.NullReferenceException(aryClipPath[i]);
			
			ApplyRootMotionBoneName(imp, imp.transformPaths[1]);
			
			string szClipName 	= imp.assetPath.Substring(
				imp.assetPath.LastIndexOf('@') + 1);
			szClipName 			= szClipName.Remove(szClipName.LastIndexOf('.'));
			
			ModelImporterClipAnimation clipImp = new ModelImporterClipAnimation ();
			if (imp.clipAnimations.Length > 0)
				clipImp = imp.clipAnimations[0];
			
			// load animation clip
			AnimationClip clip = AssetDatabase.LoadAssetAtPath(imp.assetPath, typeof(AnimationClip)) as AnimationClip;
			if (clip)
			{
				AnimationClipSettings set = AnimationUtility.GetAnimationClipSettings(clip);
				if (set != default(AnimationClipSettings))
				{
					clipImp.firstFrame 	= set.startTime * clip.frameRate;
					clipImp.lastFrame 	= set.stopTime  * clip.frameRate;
				}
			}
			
			clipImp.maskType				= ClipAnimationMaskType.CreateFromThisModel;
			clipImp.keepOriginalOrientation = true;
			clipImp.keepOriginalPositionXZ	= true;
			clipImp.keepOriginalPositionY	= true;
			clipImp.lockRootRotation		= true;
			clipImp.lockRootHeightY			= true;
			clipImp.name					= szClipName;
			
			// set loop animation
			string[] aryFiliter = {
				"idle", "move", "run", "walk", "fly", "turn"
			};
			foreach(string fliter in aryFiliter)
			{
				if (szClipName.ToLower().Contains(fliter))
				{
					clipImp.loopTime = true;
					break;
				}
			}
			
			imp.clipAnimations = new ModelImporterClipAnimation[]{clipImp};
			
			// reset model importer
			imp.SaveAndReimport();
			
			Object[] aryClip = AssetDatabase.LoadAllAssetsAtPath(imp.assetPath);
			for(int c=0; c<aryClip.Length; c++)
			{
				Object o = aryClip[c];
				
				if (o.GetType() == typeof(AnimationClip) && !o.name.Contains(SearchFileType.preview.ToString()))
				{
					Vector3 vStatePosition = new Vector3(machine.entryPosition.x + 200, machine.entryPosition.y + i * 65, 0);
					
					// create animator state
					UnityEditor.Animations.AnimatorState state = machine.AddState(o.name, vStatePosition);
					if (state)
					{
						state.motion = o as Motion;
						
						// set default state
						if (state.name.ToLower().Contains(aryFiliter[0]))
						{
							machine.defaultState = state;
						}
					}
				}
			}
		}
	}
Пример #13
0
	void OnPreprocessModel()
	{
		ModelImporter modelImporter = assetImporter as ModelImporter;

        modelImporter.materialName = ModelImporterMaterialName.BasedOnMaterialName;
        modelImporter.globalScale = 1;
		
		FileInfo fileInfo = new FileInfo (assetPath);
		if (fileInfo.Extension.ToLower() != ".fbx")
		{
			return;
		}
		
		string animConfigPath = Path.Combine (fileInfo.Directory.FullName, 
		                                      fileInfo.Name.Substring(0, fileInfo.Name.Length-4) + ".txt");
		
		if (File.Exists(animConfigPath))
		{
			StreamReader fileReader = new StreamReader(animConfigPath);
			List<string> fileLines = new List<string>();
			string line;
			int count = 0;
			while((line=fileReader.ReadLine()) != null)
			{
				fileLines.Add(line);
				count ++;
				if(count > 10)
					break;
			}
			
			List<AnimEntry> animEntryList = new List<AnimEntry>();
			foreach(string l in fileLines)
			{
				string[] contentAry = l.Split(new char[]{':', '-'});
				if(contentAry.Length == 3)
				{
					AnimEntry animEntry = new AnimEntry();
					animEntry.Name = contentAry[0];
					if(int.TryParse(contentAry[1], out animEntry.StartFrame) &&
					   int.TryParse(contentAry[2], out animEntry.EndFrame))
					{
						animEntryList.Add(animEntry);
					}
				}
			}
			
			if(animEntryList.Count > 0)
			{
				modelImporter.animationType = ModelImporterAnimationType.Legacy;
				modelImporter.importAnimation = true;

				ModelImporterClipAnimation[] clips = new ModelImporterClipAnimation[animEntryList.Count];
				
				int index = 0;
				foreach(AnimEntry animEntry in animEntryList)
				{
					ModelImporterClipAnimation clipAnim = new ModelImporterClipAnimation();
                    if(animEntry.Name == "run" || animEntry.Name == "ready" || animEntry.Name == "idle" || animEntry.Name == "stand" || animEntry.Name == "airStay")
                        clipAnim.wrapMode = WrapMode.Loop;

					clipAnim.name = animEntry.Name;
					clipAnim.firstFrame = animEntry.StartFrame;
					clipAnim.lastFrame = animEntry.EndFrame;

					clips[index] = clipAnim;
					index ++;
				}
				modelImporter.clipAnimations = clips;
			}
		}
	}
Пример #14
0
    private static void 加载(string strFilePath, ModelImporter modelImporter)
    {
        List <string> listConfigData = new List <string>(16);

        try
        {
            string strModeFileFullPath =
                Application.dataPath.Remove(Application.dataPath.LastIndexOf('/') + 1) + strFilePath;
            string strConfigFileFullPath =
                strModeFileFullPath.Remove(strModeFileFullPath.LastIndexOf('.')) +
                string.Format(".Animation{0}", strExtension);
            using (Stream file = File.Open(strConfigFileFullPath, FileMode.Open))
            {
                using (StreamReader reader = new StreamReader(file))
                {
                    listConfigData.Clear();
                    while (!reader.EndOfStream)
                    {
                        listConfigData.Add(reader.ReadLine());
                    }
                }
            }
        }
        catch
        {
            Debug.LogError(string.Format("{0}.Animation{1}文档加载失败", Selection.activeObject.name, strExtension));
            return;
        }

        Dictionary <string, ModelImporterClipAnimation> dictAnimations = new Dictionary <string, ModelImporterClipAnimation>(32);

        for (int i = 0; i < listConfigData.Count; i++)
        {
            string   data    = listConfigData[i];
            string[] strData = data.Split('-');
            if (strData.Length < 3)
            {
                Debug.LogError(string.Format("{0}数据分割错误", data));
                continue;
            }

            int firstFrame;
            if (!int.TryParse(strData[0], out firstFrame))
            {
                Debug.LogError(string.Format("{0}第1个数据有误", data));
                continue;
            }

            int lastFrame;
            if (!int.TryParse(strData[1], out lastFrame))
            {
                Debug.LogError(string.Format("{0}第2个数据有误", data));
                continue;
            }

            if (strData[2].Equals(string.Empty))
            {
                Debug.LogError(string.Format("{0}第3个数据有误,请检查文件编码", data));
                continue;
            }

            string name = strData[2].Replace("\r", string.Empty);
            if (dictAnimations.ContainsKey(name))
            {
                Debug.LogError(string.Format("{0}名称重复", data));
                continue;
            }

            WrapMode wrapMode = WrapMode.Default;
            //循环模式(可选)
            if (strData.Length > 3)
            {
                switch (strData[3])
                {
                case "Loop":
                    wrapMode = WrapMode.Loop;
                    break;

                case "PingPong":
                    wrapMode = WrapMode.PingPong;
                    break;

                case "ClampForever":
                    wrapMode = WrapMode.ClampForever;
                    break;

                case "Once":
                    wrapMode = WrapMode.Once;
                    break;

                default:
                    break;
                }
            }

            //填入数据【开始帧-结束帧-命名】
            ModelImporterClipAnimation animation = new ModelImporterClipAnimation();
            animation.firstFrame = firstFrame;
            animation.lastFrame  = lastFrame;
            animation.wrapMode   = wrapMode;
            animation.loopTime   = wrapMode == WrapMode.Loop;
            animation.name       = name;
            dictAnimations.Add(name, animation);
        }

        List <ModelImporterClipAnimation> listAnimations原 = new List <ModelImporterClipAnimation>(modelImporter.clipAnimations);

        //原来的跟新的比较,重复的就修改,不重复的就删除
        for (int i = 0; i < listAnimations原.Count; i++)
        {
            ModelImporterClipAnimation animation原 = listAnimations原[i];
            bool is重复 = false;
            foreach (KeyValuePair <string, ModelImporterClipAnimation> kvpClip in dictAnimations)
            {
                ModelImporterClipAnimation animation新 = kvpClip.Value;
                //修改原来的
                if (animation原.name == animation新.name)
                {
                    animation原.firstFrame = animation新.firstFrame;
                    animation原.lastFrame  = animation新.lastFrame;
                    animation原.wrapMode   = animation新.wrapMode;
                    animation原.loopTime   = animation新.loopTime;
                    is重复 = true;
                    break;
                }
            }

            //循环出来之后都不匹配的就是多余的,把他删了
            if (!is重复)
            {
                listAnimations原.RemoveAt(i);
                i--;
            }
        }

        //listAnimations新用来对应文本的顺序
        List <ModelImporterClipAnimation> listAnimations新 = new List <ModelImporterClipAnimation>(dictAnimations.Count);

        listAnimations新 = new List <ModelImporterClipAnimation>(dictAnimations.Count);
        foreach (KeyValuePair <string, ModelImporterClipAnimation> kvpClip in dictAnimations)
        {
            bool is重复 = false;
            for (int i = 0; i < listAnimations原.Count; i++)
            {
                animationy原 = listAnimations原[i];
                if (animationy原.name == kvpClip.Key)
                {
                    listAnimations新.Add(animationy原);
                    is重复 = true;
                    break;
                }
            }

            if (!is重复)
            {
                listAnimations新.Add(kvpClip.Value);
            }
        }

        //刷新界面:更改Selection.activeObject为null再换回去
        UnityEngine.Object modelObject = Selection.activeObject;
        Selection.activeObject       = null;
        modelImporter.clipAnimations = listAnimations新.ToArray();
        modelImporter.SaveAndReimport();
        Selection.activeObject = modelObject;

        //注:当clipAnimations减少时使用下面代码刷新后,检视面板报错
        //EditorUtility.SetDirty(modelObject);
        //2019版本刷新检视面板还需要下面代码
//#if UNITY_2019_1_OR_NEWER
//        InternalEditorUtility.RepaintAllViews();
//#endif
    }
        void ShowAnimatorModel()
        {
            _fbxModel = (GameObject)CreateObjectField("model", _fbxModel, typeof(GameObject));

            string path = AssetDatabase.GetAssetPath(_fbxModel);

            ModelImporter modelIm = (ModelImporter)ModelImporter.GetAtPath(path);
            //		AnimationClip newClip = AssetDatabase.LoadAssetAtPath(path, typeof(AnimationClip)) as AnimationClip;

            EditorGUILayout.BeginHorizontal();
            CreateLabel("name");
            CreateLabel("start");
            CreateLabel("end");
            CreateLabel("isLooping");
            EditorGUILayout.EndHorizontal();

            if (modelIm == null)
                return;
            ModelImporterClipAnimation[] animations = modelIm.clipAnimations;
            for (int pos = 0; pos < animations.Length; pos++)
            {
                EditorGUILayout.BeginHorizontal();
                animations[pos].name = CreateStringField(animations[pos].name);
                animations[pos].firstFrame = CreateFloatField(animations[pos].firstFrame);
                animations[pos].lastFrame = CreateFloatField(animations[pos].lastFrame);
                animations[pos].loop = CreateCheckBox(animations[pos].loop);
                //			animations[pos].
                CreateLabel(animations[pos].loop.ToString());
                EditorGUILayout.EndHorizontal();
            }
            if (CreateSpaceButton("Insert"))
            {
                ModelImporterClipAnimation[] newAnim = new ModelImporterClipAnimation[animations.Length + 1];
                animations.CopyTo(newAnim, 0);
                animations = newAnim;
                animations[animations.Length - 1] = animations[0];

            }
            if (CreateSpaceButton("Sub"))
            {
                ModelImporterClipAnimation[] newAnim = new ModelImporterClipAnimation[animations.Length - 1];
                System.Array.Copy(animations, newAnim, newAnim.Length);
                animations = newAnim;
            }
            if (GUI.changed)
            {
                modelIm.clipAnimations = animations;

                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }
        }
        void OnPostprocessModel(GameObject obj)
        {
            ModelImporter importer = assetImporter as ModelImporter;
            string path = importer.assetPath;
            //fetch animation config from ../[name].txt
            int extensionSplit = path.LastIndexOf ('.');
            string configPath = path.Remove (extensionSplit) + ".txt";
            if (!File.Exists (configPath)) return;
            Debug.Log ("Postprocessing model @ path : " + path);
            StreamReader reader = new StreamReader (configPath);
            List<ModelImporterClipAnimation> clips = new List<ModelImporterClipAnimation> ();
            string[] elements;
            ModelImporterClipAnimation clip;
            int lineNumber = 0;
            int eventTotal = 0;
            string[] eventParameters;
            char[] eventSeperators = new char[] {'@', ';'};
            float frameLength;
            string line;
            try {
            while (!reader.EndOfStream) {
                    line = reader.ReadLine ();
                    lineNumber++;
                    if (line.StartsWith("//")) continue;
                    if (!requiredColumnsDefined) {
                        if (line.StartsWith ("#")) {
                            string[] argument = line.Split (new char[] {' ', '=', '[', ']', '\'', '\"'}, System.StringSplitOptions.RemoveEmptyEntries);
                            //Debug.Log ("argument[0] = " + argument[0]);
                            if (argument[0].Equals("#seperator")) {
                                seperator = new string[] {argument[1]};
                                //Debug.Log ("seperator = " + seperator[0]);
                            } else {

                            }
                        } else {
                            string[] columns = line.Split (seperator, System.StringSplitOptions.RemoveEmptyEntries);
                            for (int o = 0; o < columns.Length; o++) {
                                //Debug.Log (columns[o]);
                                for (Property r = (Property)0; r < Property._Count; r++)
                                {
                                    if (columns[o].Equals (r.ToString ())) {
                                        column[(int)r] = o;
                                        columnDefined++;
                                    }
                                }
                            }
                            if (!(requiredColumnsDefined = (columnDefined == (int)Property._Count))) {
                                Debug.LogError ("property not found!");
                                return;
                            }
                        }
                    } else {
                        elements = line.Split(seperator, System.StringSplitOptions.None);

                        clip = new ModelImporterClipAnimation ();
                        clips.Add (clip);
                        clip.name = elements[column[(int)Property.name]];
                        clip.firstFrame = float.Parse (elements[column[(int)Property.first]]);
                        clip.lastFrame = float.Parse (elements[column[(int)Property.last]]);
                        if (elements.Length > column[(int)Property.loop])
                            clip.loopTime = bool.Parse (elements[column[(int)Property.loop]]);
                        if (elements.Length > column[(int)Property.events])
                        {
                            string eventsStr = elements[column[(int)Property.events]];
                            Debug.Log(clip.name + "------------------->" + eventsStr);
                            if (!string.IsNullOrEmpty(eventsStr))
                            {
                                frameLength = clip.lastFrame - clip.firstFrame;
                                eventParameters = eventsStr.Split(eventSeperators);
                                Debug.Log(clip.name + "------------------->eventParameters------>" + eventParameters.Length.ToString());
                                if (eventParameters.Length % 3 != 0) throw new System.FormatException("event parameters' size mismatch.");
                                int eventCount = eventParameters.Length / 3;
                                AnimationEvent[] events = new AnimationEvent[eventCount];
                                for (int i = 0; i < eventCount; i++)
                                {
                                    events[i] = new AnimationEvent();
                                    eventTotal++;
                                    events[i].functionName = ((AnimationEventFunction)(int.Parse(eventParameters[3 * i]))).ToString();
                                    if (!string.IsNullOrEmpty(eventParameters[3 * i + 1]))
                                        events[i].intParameter = int.Parse(eventParameters[3 * i + 1]);

                                    //events[i].time = (float.Parse(eventParameters[3 * i + 2]) - clip.firstFrame) / frameLength;
                                    events[i].time = (float.Parse(eventParameters[3 * i + 2])) / frameLength;

                                    Debug.Log(events[i].functionName +"["+clip.firstFrame.ToString()+":"+clip.lastFrame.ToString()+"] at " + events[i].time.ToString());
                                }
                                clip.events = events;
                            }
                        }
                    }
            }
            }
            catch (System.Exception e) {
            Debug.LogError ("exception on line " + lineNumber + " : " + e.Message);
            }
            finally {
                reader.Close ();
            }
            /*
            for (int i = 0; i < importedAnims.Length; i++) {
            clips[i] = new ModelImporterClipAnimation ();
            clips[i].name = "clip " + i;
            clips[i].firstFrame = importedAnims[i].firstFrame;
            clips[i].lastFrame = importedAnims[i].lastFrame;
            clips[i].loop = importedAnims[i].loop;
            AnimationEvent evStart = new AnimationEvent ();
            evStart.functionName = "AnimationStart_";
            evStart.time = 0;
            AnimationEvent evEnd = new AnimationEvent ();
            evEnd.functionName = "AnimationEnd_";
            evEnd.time = 1;
            clips[i].events = new AnimationEvent[] {evStart, evEnd};
            }
            */
            importer.clipAnimations = clips.ToArray();
            Debug.Log ("Postprocessed model @ path : " + path + ". animation : " + clips.Count + " events : " + eventTotal);
        }