private static AnimationTemplate[] LoadAllTemplates(string path) { var max = 0; foreach (AnimationNames name in Enum.GetValues(typeof(AnimationNames))) { var asInt = (int)name; if (asInt > max) { max = asInt; } } var ret = new AnimationTemplate[max + 1]; foreach (var file in Directory.EnumerateFiles(path, "*.txt")) { var name = Path.GetFileNameWithoutExtension(file); if (!Enum.TryParse <AnimationNames>(name, ignoreCase: true, result: out var parsedName)) { continue; } var template = LoadTemplate(parsedName, file); ret[(int)parsedName] = template; } return(ret); }
public void Play(string clipName, bool randomStart, bool isLoop) { AvatarAnimationClip clipObj = AnimationTemplate.GetClip(clipName); if (clipObj == null) { return; } CurrClip = clipObj; isPlaying = true; IsLoop = isLoop; lostTime = 0; int currFrame = randomStart ? UnityEngine.Random.Range(0, CurrClip.Frames.Length - 1) : 0; ManualPlayByFrame(clipName, currFrame, isLoop); }
public Animation(AnimationTemplate template) { Template = template; }