Created
January 7, 2016 04:38
-
-
Save peroon/9c07cb5390056917c6f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| IEnumerator LoadFromTextData(){ | |
| string path; | |
| #if UNITY_EDITOR | |
| path = "file://" + Application.streamingAssetsPath + "/TextData/PhaseTime.txt"; | |
| #else | |
| path = Application.streamingAssetsPath + "/TextData/PhaseTime.txt"; | |
| #endif | |
| Debug.Log ("path : " + path); | |
| string text; | |
| WWW data = new WWW(path); | |
| yield return data; | |
| if (string.IsNullOrEmpty (data.error)) { | |
| text = data.text; | |
| } else { | |
| Debug.Log ("テキストロードエラー"); | |
| text = "text load error"; | |
| } | |
| // 空白除去 | |
| text = Regex.Replace(text, @"\s+", ""); | |
| // Debug.Log ("テキストデータ : " + text); | |
| // セミコロンで切る | |
| string[] separator = {";"}; | |
| string[] splitted = text.Split(separator, System.StringSplitOptions.RemoveEmptyEntries); | |
| phaseList = new List<Phase> (); | |
| for (int i = 0; i < splitted.Length; i++) { | |
| string rowData = splitted [i]; // 1行 | |
| // カンマで切る | |
| string[] separator2 = {","}; | |
| string[] splitted2 = rowData.Split(separator2, System.StringSplitOptions.RemoveEmptyEntries); | |
| var phase = new Phase (); | |
| phase.startTime = int.Parse (splitted2 [0]); | |
| phase.endTime = int.Parse (splitted2 [1]); | |
| phaseList.Add (phase); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment