private void displayEditItem() { GUILayout.BeginHorizontal(); if (selectedItemIndex > 0) { if (GUILayout.Button("Privious")) { selectedItemIndex--; } } if (selectedItemIndex < Enum.GetValues(typeof(MyMaterial)).Length - 1) { if (GUILayout.Button("Next")) { selectedItemIndex++; } } if (GUILayout.Button("Last")) { selectedItemIndex = Enum.GetValues(typeof(MyMaterial)).Length - 1; } mat = (MyMaterial)EditorGUILayout.EnumPopup("Item: ", mat); MaterialSetting ms = database.getMaterialSetting(mat); GUILayout.EndHorizontal(); ms.isPlaceable = GUILayout.Toggle(ms.isPlaceable, "Is placeable: "); if (ms.isPlaceable) { //IF IS BLOCK ms.useCustomeBlockModel = GUILayout.Toggle(ms.useCustomeBlockModel, "Use Custome Block Model"); if (ms.useCustomeBlockModel == false) { textureType = (TextureType)EditorGUILayout.EnumPopup("Texture Type", textureType); switch (textureType) { case (TextureType.NORMAL): { ms.texture = (Texture2D)EditorGUILayout.ObjectField("Texture", ms.texture, typeof(Texture2D), false); break; } case (TextureType.SIDE): { ms.textureSIDE = (Texture2D)EditorGUILayout.ObjectField("Texture", ms.textureSIDE, typeof(Texture2D), false); break; } case (TextureType.UP): { ms.textureUP = (Texture2D)EditorGUILayout.ObjectField("Texture", ms.textureUP, typeof(Texture2D), false); break; } case (TextureType.DOWN): { ms.textureDOWN = (Texture2D)EditorGUILayout.ObjectField("Texture", ms.textureDOWN, typeof(Texture2D), false); break; } case (TextureType.NORTH): { ms.textureNORTH = (Texture2D)EditorGUILayout.ObjectField("Texture", ms.textureNORTH, typeof(Texture2D), false); break; } case (TextureType.SOUTH): { ms.textureSOUTH = (Texture2D)EditorGUILayout.ObjectField("Texture", ms.textureSOUTH, typeof(Texture2D), false); break; } case (TextureType.WEST): { ms.textureWEST = (Texture2D)EditorGUILayout.ObjectField("Texture", ms.textureWEST, typeof(Texture2D), false); break; } case (TextureType.EAST): { ms.textureEAST = (Texture2D)EditorGUILayout.ObjectField("Texture", ms.textureEAST, typeof(Texture2D), false); break; } default: { ms.texture = (Texture2D)EditorGUILayout.ObjectField("Texture", ms.texture, typeof(Texture2D), false); break; } } //Search GUILayout.Space(10f); GUILayout.BeginHorizontal(); if (GUILayout.Button("Auto Fill")) { searchKeyword = mat.ToString().Replace("_", " ").ToLower(); } searchKeyword = GUILayout.TextField(searchKeyword); if (GUILayout.Button("Search Image")) { WebHandler.getTextures(webSearchTexture, searchKeyword); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); webSearchSelected = GUILayout.SelectionGrid(webSearchSelected, webSearchTexture.ToArray(), 8); GUILayout.EndHorizontal(); if (GUILayout.Button("Use This Image As Texture")) { if (File.Exists("Assets/Resources/Texture/" + mat + "_" + textureType + ".png")) { File.Delete("Assets/Resources/Texture/" + mat + "_" + textureType + ".png"); } File.WriteAllBytes("Assets/Resources/Texture/" + mat + "_" + textureType + ".png", ((Texture2D)webSearchTexture[webSearchSelected]).EncodeToPNG()); AssetDatabase.Refresh(); Texture2D t = Resources.Load <Texture2D>("Texture\\" + mat + "_" + textureType); t.filterMode = FilterMode.Point; ms.setTexture(textureType, t); if (ms.material == null) { Material material = Resources.Load <Material>("Material\\" + mat); if (material == null) { File.Copy(Application.dataPath + "/Resources/Material/DEFAULT.mat", Application.dataPath + "/Resources/Material/" + mat + ".mat"); material = Resources.Load <Material>("Material\\" + mat); } ms.material = material; } AssetDatabase.Refresh(); } editDropTable(ms.dropTable); } else { ms.customeBlockModel = (GameObject)EditorGUILayout.ObjectField("Custome Block Model", ms.customeBlockModel, typeof(GameObject), false); } } else { //IF IS ITEM ms.texture = (Texture2D)EditorGUILayout.ObjectField("Texture", ms.texture, typeof(Texture2D), false); //Search GUILayout.Space(10f); GUILayout.BeginHorizontal(); searchKeyword = GUILayout.TextField(searchKeyword); if (GUILayout.Button("Auto Fill")) { searchKeyword = mat.ToString().Replace("_", " ").ToLower(); } if (GUILayout.Button("Search Image")) { WebHandler.getTextures(webSearchTexture, searchKeyword, transparent: true); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); webSearchSelected = GUILayout.SelectionGrid(webSearchSelected, webSearchTexture.ToArray(), 8); GUILayout.EndHorizontal(); if (GUILayout.Button("Use This Image As Texture")) { if (File.Exists("Assets/Resources/Texture/" + mat + "_" + textureType + ".png")) { File.Delete("Assets/Resources/Texture/" + mat + "_" + textureType + ".png"); } File.WriteAllBytes("Assets/Resources/Texture/" + mat + "_" + textureType + ".png", ((Texture2D)webSearchTexture[webSearchSelected]).EncodeToPNG()); AssetDatabase.Refresh(); Texture2D t = Resources.Load <Texture2D>("Texture\\" + mat + "_" + textureType); t.filterMode = FilterMode.Point; ms.setTexture(textureType, t); if (ms.material == null) { Material material = Resources.Load <Material>("Material\\" + mat); if (material == null) { File.Copy(Application.dataPath + "/Resources/Material/DEFAULT.mat", Application.dataPath + "/Resources/Material/" + mat + ".mat"); material = Resources.Load <Material>("Material\\" + mat); } ms.material = material; } AssetDatabase.Refresh(); } } //Name ms.desplayName = EditorGUILayout.TextField("Display Name: ", ms.desplayName); //DESCRIPTION ms.description = EditorGUILayout.TextField("Description: ", ms.description); GUILayout.Space(10f); }