public override string SetText(string NewText, bool sync = true) { ImageDataList = new List <string>(NewText.Split(new string[] { ImageDataDelimiter }, StringSplitOptions.None)); List <string> NameList = (ImageDataList[0] == string.Empty) ? new List <string>() : new List <string>(ImageDataList[0].Split(new string[] { ImageNameDelimiter }, StringSplitOptions.None)); ImageDataList.RemoveAt(0); for (int i = 0; i < ImageDataList.Count; ++i) { MaterialList.Add(PNGTextureConstruct.MaterialConstruct(ImageDataList[i], NameList[i])); } return(string.Empty); }
private string SetStatsText(string ImageData) { PNGTextureConstruct.TextureStats(ImageData); return(string.Format("Width : {0}\nHeight : {1}\nBit Depth : {2}\nColor Type : {3}", PNGTextureConstruct.Width, PNGTextureConstruct.Height, PNGTextureConstruct.BitDepth, PNGTextureConstruct.ColorType)); }
public override bool ExtraGUI() { Rect Panel1 = new Rect(250f, 100f, 1030f, 600f); GUILayout.BeginArea(Panel1, "ImageDataStorageBlock", GUI.skin.window); GUILayout.BeginVertical(GUILayout.Height(490)); GUILayout.Label("State"); GUILayout.TextArea(StatsText, GUILayout.Height(130)); if (SelectID != -1) { AddDataMenu = false; ImageData = string.Empty; StatsText = SetStatsText(ImageDataList[SelectID]); if (GUILayout.Button("Delete", GUILayout.ExpandHeight(false))) { ImageDataList.RemoveAt(SelectID); UnityEngine.Object.Destroy(MaterialList[SelectID]); MaterialList.RemoveAt(SelectID--); StatsText = string.Empty; } } if (AddDataMenu) { GUILayout.BeginHorizontal(); GUILayout.Label("Set Name : ", GUILayout.MaxWidth(100)); ImageName = GUILayout.TextField(ImageName); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("File Path : ", GUILayout.MaxWidth(100)); SetFilePath = GUILayout.TextField(SetFilePath); GUILayout.EndHorizontal(); if (GUILayout.Button("Load", GUILayout.ExpandHeight(false))) { ImageData = Convert.ToBase64String(ImageConversion.EncodeToPNG(new WWW(SetFilePath).texture)); StatsText = SetStatsText(ImageData); } if (ImageData != string.Empty && GUILayout.Button("Add To List", GUILayout.ExpandHeight(false))) { ImageDataList.Add(ImageData); MaterialList.Add(PNGTextureConstruct.MaterialConstruct(ImageData, ImageName)); ImageData = string.Empty; StatsText = string.Empty; AddDataMenu = false; SyncroniseDataUpLoad(); } } GUILayout.EndVertical(); if (!AddDataMenu && GUILayout.Button("Add New Data", GUILayout.Height(40))) { SelectID = -1; StatsText = string.Empty; AddDataMenu = true; } bool result = GuiCommon.DisplayCloseButton((int)Panel1.width); GUILayout.EndArea(); Gui_ImageDataList(); return(result); }