IEnumerator ListAllData(List <string> data) { #region 前処理:アトラクターの一時停止とシステム状態の遷移 photoManager.AttractorDisable(); if ((SystemManager.systemState & SystemManager.SystemState.MAIN) == SystemManager.SystemState.MAIN) { SystemManager.systemState = ~SystemManager.SystemState.MAIN & SystemManager.systemState; SystemManager.systemState |= SystemManager.SystemState.LOAD; } #endregion CSVTagger tagger = GetComponent <CSVTagger>(); List <List <string> > csvData = new List <List <string> >(); List <List <string> > csvWord = new List <List <string> >(); foreach (string dataName in data) { string csvText = File.ReadAllText(dataName); if (csvText != null) { string[] metadataPath = dataName.Split('/'); #region keyCodeの生成とcsvのリスト化 if (metadataPath[metadataPath.Length - 1].Contains("data")) { csvData.AddRange(tagger.CSVToList(csvText)); photoManager.CreateKeydataCode(csvData); photoManager.CreateMaxMinCode(csvData); } else if (metadataPath[metadataPath.Length - 1].Contains("keyword")) { csvWord.AddRange(tagger.CSVToList(csvText)); photoManager.CreateKeywordCode(csvWord); } #endregion } } //int counter = (int)(1 / Time.deltaTime); #region タグ付け foreach (DflipPhoto a in photoManager.photos) { string filename = a.fileName; if (csvData != null) { tagger.TaggingData(csvData, a, filename); } if (csvWord != null) { tagger.TaggingWord(csvWord, a, filename); } //if (counter < 1) //{ // text.text = "Now Loading . . ."; // counter = (int)((1/2) * (1 / Time.deltaTime)); //} //else if (counter > 1 && counter < (int)((1/6) * (1/ Time.deltaTime))) //{ // text.text = "Now Loading ."; //} //else if (counter > (int)((1 / 6) * (1 / Time.deltaTime)) && counter < (int)((1 / 3) * (1 / Time.deltaTime))) //{ // text.text = "Now Loading . ."; //} //counter--; yield return(null); } #endregion #region 後処理 GetComponent <GUIManager>().CreateButtons(); GetComponent <GUIManager>().GUIInteractable(); #region exifに関しては全画像についてexifデータが揃っていなければinteractableをオフにする if (checker != photoManager.photos.Count) { gameObject.GetComponent <GUIManager>().Deinteractable("撮影年月"); } else { photoManager.CreateMaxMinCode("撮影年月"); } #endregion SystemManager.systemState = ~SystemManager.SystemState.LOAD & SystemManager.systemState; SystemManager.systemState |= SystemManager.SystemState.MAIN; photoManager.AttractorEnable(); #endregion }
IEnumerator ListAllFiles(List <string> files, List <string> data) { #region 前処理:アトラクターの一時停止とシステム状態の遷移 photoManager.AttractorDisable(); if ((SystemManager.systemState & SystemManager.SystemState.MAIN) == SystemManager.SystemState.MAIN) { SystemManager.systemState = ~SystemManager.SystemState.MAIN & SystemManager.systemState; SystemManager.systemState |= SystemManager.SystemState.LOAD; } #endregion #region デフォルトのメタデータのキーコードを生成 photoManager.CreateKeydataCode("輝度"); photoManager.CreateKeydataCode("彩度"); photoManager.CreateKeydataCode("撮影年月"); photoManager.CreateKeywordCode("カラー"); #endregion #region keyCodeの生成とcsvのリスト化 CSVTagger tagger = GetComponent <CSVTagger>(); List <List <string> > csvData = new List <List <string> >(); List <List <string> > csvWord = new List <List <string> >(); foreach (string dataName in data) { string csvText = File.ReadAllText(dataName); if (csvText != null) { string[] metadataPath = dataName.Split('/'); if (metadataPath[metadataPath.Length - 1].Contains("data")) { csvData.AddRange(tagger.CSVToList(csvText)); photoManager.CreateKeydataCode(csvData); photoManager.CreateMaxMinCode(csvData); } else if (metadataPath[metadataPath.Length - 1].Contains("keyword")) { csvWord.AddRange(tagger.CSVToList(csvText)); photoManager.CreateKeywordCode(csvWord); } } } #endregion //ファイルを均等な配列で生成 int column = (int)Mathf.Sqrt(files.Count) + 1; var span_x = (AutoDisplayAdjuster.Instance.NormalizedSize.x) / (column + 1); var span_y = (AutoDisplayAdjuster.Instance.NormalizedSize.y) / (column + 1); Vector3 createPosition = new Vector3(AutoDisplayAdjuster.Instance.BottomLeft().x + photoMargin + span_x, AutoDisplayAdjuster.Instance.TopRight().y, 0); for (var i = 0; i < files.Count; i++) { GameObject photo = new GameObject() as GameObject; GameObject sprite = new GameObject() as GameObject; var sp = sprite.AddComponent <SpriteRenderer>(); sp.material = Instantiate(spriteMaterial); sp.material.SetFloat("_Offset", 0.1f); var _p = photo.AddComponent <DflipPhoto>(); var _s = sprite.AddComponent <PhotoSprite>(); _p.sprite = _s; _p.ID = i; string[] temp = files[i].Split('/'); _p.fileName = temp[temp.Length - 1].Split('.')[0]; #region タグ付け string filename = _p.fileName; if (csvData != null) { tagger.TaggingData(csvData, _p, filename); } if (csvWord != null) { tagger.TaggingWord(csvWord, _p, filename); } #endregion //画像ロード if (i >= files.Count - 1) { last = true; } Bitmap bit = TaggingFromExif(files[i], _p); _s.Load(files[i], photo, bit); #region D-FLIPアルゴリズムの衝突判定用コライダ var boxCollider = photo.AddComponent <BoxCollider>(); boxCollider.material = pm; boxCollider.size = new Vector3(sprite.GetComponent <SpriteRenderer>().bounds.size.x, sprite.GetComponent <SpriteRenderer>().bounds.size.y, 0) + 0.3f * Vector3.one; boxCollider.isTrigger = true; Rigidbody rigid = photo.AddComponent <Rigidbody>(); rigid.constraints = RigidbodyConstraints.FreezePositionZ; rigid.freezeRotation = true; rigid.useGravity = false; rigid.drag = 1f; #endregion #region タッチ用コライダ var boxCollider_s = sprite.AddComponent <BoxCollider>(); boxCollider_s.material = pm; boxCollider_s.size = sprite.GetComponent <SpriteRenderer>().bounds.size; boxCollider_s.isTrigger = true; Rigidbody rigid_s = sprite.AddComponent <Rigidbody>(); rigid_s.constraints = RigidbodyConstraints.FreezePositionZ; rigid_s.freezeRotation = true; rigid_s.useGravity = false; rigid_s.drag = 1f; sprite.AddComponent <PhotoInteraction>(); #endregion #region 初期位置&スケール photo.transform.localPosition = createPosition + PhotoManager.offset; sprite.transform.localPosition = createPosition; sp.sortingOrder = 1; photo.transform.localScale = new Vector3(0.05f, 0.05f, 1f); sprite.transform.localScale = photo.transform.localScale; #endregion photoManager.AddPhoto(_p); #region CreatePositionの調整 if ((i + 1) % column == 0) { createPosition = new Vector3(AutoDisplayAdjuster.Instance.BottomLeft().x + photoMargin, createPosition.y, createPosition.z); createPosition -= new Vector3(0, span_y, 0); } createPosition += new Vector3(span_x, 0, 0); #endregion yield return(null); } #region 後処理 GetComponent <GUIManager>().CreateButtons(); GetComponent <GUIManager>().GUIInteractable(); #region exifに関しては全画像についてexifデータが揃っていなければinteractableをオフにする if (checker != photoManager.photos.Count) { gameObject.GetComponent <GUIManager>().Deinteractable("撮影年月"); } else { photoManager.CreateMaxMinCode("撮影年月"); } #endregion SystemManager.systemState = ~SystemManager.SystemState.LOAD & SystemManager.systemState; SystemManager.systemState |= SystemManager.SystemState.MAIN; photoManager.AttractorEnable(); #endregion }