public static FMCPose LoadPose(string file) { file += ".pos"; if (fmcPose.ContainsKey(file)) { return(fmcPose[file]); } FMCPose pose = new FMCPose(); TextAsset asset = Resources.Load <TextAsset>(file); if (asset == null) { return(null); } string text = System.Text.Encoding.ASCII.GetString(asset.bytes); string[] pos = text.Split(new char[] { '\r', '\n' }, System.StringSplitOptions.RemoveEmptyEntries); int idx = 0; MiniPose po = null; for (int i = 0; i < pos.Length; i++) { string[] eachobj = pos[i].Split(new char[] { ' ', '\t' }, System.StringSplitOptions.RemoveEmptyEntries); if (eachobj[0] == "pose") { po = new MiniPose(); po.idx = idx; pose.pos.Add(po); idx++; } if (eachobj[0] == "start") { if (po != null) { po.start = int.Parse(eachobj[1]); } } if (eachobj[0] == "end") { if (po != null) { po.end = int.Parse(eachobj[1]); } } } fmcPose.Add(file, pose); return(pose); }
public FMCPose LoadPose(string file) { string file_no_ext = file; file += ".pos"; if (fmcPose.ContainsKey(file)) { return(fmcPose[file]); } byte[] body = null; if (CombatData.Ins.Chapter != null) { string path = CombatData.Ins.Chapter.GetResPath(FileExt.Pos, file_no_ext); if (!string.IsNullOrEmpty(path)) { if (File.Exists(path)) { body = File.ReadAllBytes(path); } } } if (body == null) { TextAsset asset = Resources.Load <TextAsset>(file); if (asset == null) { return(null); } body = asset.bytes; } FMCPose pose = new FMCPose(); string text = System.Text.Encoding.ASCII.GetString(body); string[] pos = text.Split(new char[] { '\r', '\n' }, System.StringSplitOptions.RemoveEmptyEntries); int idx = 0; MiniPose po = null; for (int i = 0; i < pos.Length; i++) { string[] eachobj = pos[i].Split(new char[] { ' ', '\t' }, System.StringSplitOptions.RemoveEmptyEntries); if (eachobj[0] == "pose") { po = new MiniPose(); po.idx = idx; pose.pos.Add(po); idx++; } if (eachobj[0] == "start") { if (po != null) { po.start = int.Parse(eachobj[1]); } } if (eachobj[0] == "end") { if (po != null) { po.end = int.Parse(eachobj[1]); } } } fmcPose.Add(file, pose); return(pose); }