void SetUpNode() { for (int i = 0; i < ValueSheet.dic_id_SpriteOrVideo.Count; i++) { SpriteOrVideo spriteOrVideo = ValueSheet.dic_id_SpriteOrVideo[i]; string s = "\\"; char[] r = s.ToCharArray(); char t = r[0]; string trimstr = (Application.streamingAssetsPath + "/Node/Images/").Replace('/', t); char[] trimtext = trimstr.ToCharArray(); string[] tempstr = spriteOrVideo.Path.Remove(0, trimtext.Length).Split('-'); if (spriteOrVideo.isVideo) { string strJpg = ".mp4"; char[] cha = strJpg.ToCharArray(); readJson.SetUpNodeList(i, " ", spriteOrVideo.Path, "", tempstr[1], false, tempstr[2], tempstr[3].TrimEnd(cha), spriteOrVideo.sprite, true); } else { string strJpg = ".jpg"; char[] cha = strJpg.ToCharArray(); readJson.SetUpNodeList(i, " ", " ", " ", tempstr[1], false, tempstr[2], tempstr[3].TrimEnd(cha), spriteOrVideo.sprite, false); } } //List<Sprite> tempSprite = new List<Sprite>(); //foreach (var item in ValueSheet.NodeSprites) //{ // string[] temp = item.name.Split('_'); // // Debug.Log(temp[0]); // ValueSheet.dic_id_sprite.Add(int.Parse(temp[0]), item); //} //string strJpg = ".jpg"; //char[] cha = strJpg.ToCharArray(); //// Debug.Log(ValueSheet.dic_id_sprite[4].name); //for (int i = 0; i < ValueSheet.NodeSprites.Count; i++) //{ // string[] tempstr = ValueSheet.dic_id_sprite[i].name.Split('_'); //} }
public IEnumerator SetupSpriteOrVideoDic(List <string> paths) { string s = "\\"; char[] r = s.ToCharArray(); char t = r[0]; string trimstr = (Application.streamingAssetsPath + "/Node/Images/").Replace('/', t); char[] trimtext = trimstr.ToCharArray(); for (int i = 0; i < paths.Count; i++) { if (paths[i].Contains(".jpg")) { //ID string[] temp = paths[i].Split('-'); Debug.Log(paths[i]); Debug.Log(temp.Length); string idStr = temp[0].Remove(0, trimtext.Length); int id = int.Parse(idStr); //Sprite WWW www = new WWW(paths[i]); yield return(www); Texture texture = www.texture; Sprite sprite = Sprite.Create(texture as Texture2D, new Rect(0, 0, texture.width, texture.height), Vector2.zero); if (www.isDone) { www.Dispose(); } //Create Object SpriteOrVideo spriteOrVideo = new SpriteOrVideo(false, paths[i], sprite); ValueSheet.dic_id_SpriteOrVideo.Add(id, spriteOrVideo); } else if (paths[i].Contains(".mp4")) { string[] temp = paths[i].Split('-'); string idStr = temp[0].Remove(0, trimtext.Length); int id = int.Parse(idStr); SpriteOrVideo spriteOrVideo = new SpriteOrVideo(true, paths[i]); ValueSheet.dic_id_SpriteOrVideo.Add(id, spriteOrVideo); } } }