diff --git a/Assets/Scripts/Actions/AnimationAction.cs b/Assets/Scripts/Actions/AnimationAction.cs index c211d434..d99185ca 100644 --- a/Assets/Scripts/Actions/AnimationAction.cs +++ b/Assets/Scripts/Actions/AnimationAction.cs @@ -48,7 +48,7 @@ namespace QFramework anim.Play(animName); if (reset) { - ActionKit.DelayFrame(1, () => anim.Stop()); + ActionKit.DelayFrame(1, () => anim.Stop()).StartGlobal(); } } else diff --git a/Assets/Scripts/Editor/FbxAnimListPostprocessor.cs b/Assets/Scripts/Editor/FbxAnimListPostprocessor.cs new file mode 100644 index 00000000..0f451c54 --- /dev/null +++ b/Assets/Scripts/Editor/FbxAnimListPostprocessor.cs @@ -0,0 +1,84 @@ + +using UnityEngine; +using UnityEditor; +using System.Collections; +using System.IO; +using System.Text.RegularExpressions; +using System; +using System.IO; + + +public class FbxAnimListPostprocessor : MonoBehaviour +{ + [MenuItem("Assets/SplitAnimNew")] + public static void SplitAnim() + { + UnityEngine.Object obj = Selection.activeObject; + if( null != obj ) + { + string assetPath = AssetDatabase.GetAssetPath(obj); + try + { + string fileAnim; + fileAnim = assetPath; + string ClipText = Path.ChangeExtension(fileAnim, ".txt"); + StreamReader file = new StreamReader(ClipText); + string sAnimList = file.ReadToEnd(); + file.Close(); + // + if (EditorUtility.DisplayDialog("FBX Animation Import from file", + fileAnim, "Import", "Cancel")) + { + System.Collections.ArrayList List = new ArrayList(); + ParseAnimFile(sAnimList, ref List); + + ModelImporter modelImporter = ModelImporter.GetAtPath(assetPath) as ModelImporter; + modelImporter.animationType = ModelImporterAnimationType.Legacy; + //modelImporter.clipAnimations. = true; + modelImporter.clipAnimations = (ModelImporterClipAnimation[]) + List.ToArray(typeof(ModelImporterClipAnimation)); + AssetDatabase.ImportAsset(assetPath); + + EditorUtility.DisplayDialog("导入成功", + "Number of imported clips: " + + modelImporter.clipAnimations.GetLength(0).ToString(), "OK"); + } + } + catch { } + // (Exception e) { EditorUtility.DisplayDialog("Imported animations", e.Message, "OK"); } + } + } + + static void ParseAnimFile(string sAnimList, ref System.Collections.ArrayList List) + { + Regex regexString = new Regex(" *(?[0-9]+) *- *(?[0-9]+) *(?(loop|noloop| )) *(?[^\r^\n]*[^\r^\n^ ])", + RegexOptions.Compiled | RegexOptions.ExplicitCapture); + + Match match = regexString.Match(sAnimList, 0); + while (match.Success) + { + ModelImporterClipAnimation clip = new ModelImporterClipAnimation(); + + if (match.Groups["firstFrame"].Success) + { + clip.firstFrame = System.Convert.ToInt32(match.Groups["firstFrame"].Value, 10); + } + if (match.Groups["lastFrame"].Success) + { + clip.lastFrame = System.Convert.ToInt32(match.Groups["lastFrame"].Value, 10); + } + if (match.Groups["loop"].Success) + { + clip.loop = match.Groups["loop"].Value == "loop"; + } + if (match.Groups["name"].Success) + { + clip.name = match.Groups["name"].Value; + } + + List.Add(clip); + + match = regexString.Match(sAnimList, match.Index + match.Length); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Editor/FbxAnimListPostprocessor.cs.meta b/Assets/Scripts/Editor/FbxAnimListPostprocessor.cs.meta new file mode 100644 index 00000000..968a154f --- /dev/null +++ b/Assets/Scripts/Editor/FbxAnimListPostprocessor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: deca3cf63294eda47b1155de672f9698 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Launch.cs b/Assets/Scripts/Launch.cs index 2a13b1b4..ed089f65 100644 --- a/Assets/Scripts/Launch.cs +++ b/Assets/Scripts/Launch.cs @@ -56,9 +56,8 @@ public class Launch : MonoBehaviour } - IEnumerator PreLoad() - { - yield return null; - } + + + } diff --git a/Assets/Scripts/TimeScaleController.cs b/Assets/Scripts/TimeScaleController.cs new file mode 100644 index 00000000..1e4272b6 --- /dev/null +++ b/Assets/Scripts/TimeScaleController.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TimeScaleController : MonoBehaviour +{ + + [Range(0, 10)] + public float animSpeed = 1.0f; + + +#if UNITY_EDITOR + private void Update() + { + Time.timeScale = animSpeed; + } +#endif +} diff --git a/Assets/Scripts/TimeScaleController.cs.meta b/Assets/Scripts/TimeScaleController.cs.meta new file mode 100644 index 00000000..d2e999e7 --- /dev/null +++ b/Assets/Scripts/TimeScaleController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b2c08eae7cce6c9479adebcaad5706c3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: