void OnGUI() { List <ColorPalette> foundPalettes = Asseting.FindAssetsByType <ColorPalette>(); List <float> orders = new List <float>(); foreach (ColorPalette p in foundPalettes) { orders.Add(p.order); } List <int> sorted; ArrayProcess.ListSorter(orders, out sorted); palettes = new List <ColorPalette>(); for (int i = 0; i < foundPalettes.Count; i++) { palettes.Add(foundPalettes[sorted[i]]); } GUILayout.BeginHorizontal(); GUING.Title("Found : " + palettes.Count + " Color Palettes.", false, false, 200); palettePerLine = (int)GUING.Slider(palettePerLine, 2, 7, 1, new Vector2(0, 0), "Palette Per Line", 100); paletteSize = (int)GUING.Slider(paletteSize, 200, 400, 1, new Vector2(0, 0), "Palette Size", 100); GUILayout.EndHorizontal(); DisplayPalettes(50, paletteSize, palettePerLine); /* * Color gc = GUI.backgroundColor; GUI.backgroundColor = Color.grey; * if (GUI.Button(new Rect(0,this.position.height-25,500,25), "CLOSE" )) { this.Close(); }GUI.backgroundColor = gc;*/ }
void DisplayPalette(ColorPalette palette, Rect rect, float colorW, float colorH, int countPerLine = 3) { Texture2D t = new Texture2D((int)rect.width, (int)rect.height); GUILayout.BeginArea(rect, t); //GUING.Title("<b>"+ palette.name + "</b>",false,true); style = new GUIStyle(GUI.skin.textField); style.fontStyle = FontStyle.Bold; style.alignment = TextAnchor.MiddleCenter; palette.name = GUILayout.TextField(palette.name, style, GUILayout.Width(rect.width), GUILayout.Height(16)); GUILayout.BeginHorizontal(); int x = 0; Color gc = GUI.contentColor; style = new GUIStyle(GUI.skin.label); style.fontSize = 10; style.alignment = TextAnchor.MiddleCenter; for (int i = 0; i <= palette.colors.Count; i++) { if (x % countPerLine == 0) { GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); } if (i < palette.colors.Count) { int variation = palette.variation; if (palette.variation >= palette.colors[i].colors.Count) { palette.colors[i].colors.Add(palette.colors[i].colors[palette.colors[i].colors.Count - 1]); } GUILayout.BeginVertical(); Couleur couleur = palette.colors[i]; Color c = GUI.backgroundColor; GUI.backgroundColor = couleur.colors[variation]; couleur.name = GUILayout.TextField(palette.colors[i].name, style, GUILayout.Width(colorW), GUILayout.Height(15)); if (!selecting) { couleur.colors[variation] = EditorGUILayout.ColorField(GUIContent.none, palette.colors[i].colors[variation], false, false, false, GUILayout.Width(colorW), GUILayout.Height(colorH)); } else if (GUILayout.Button("", GUILayout.Width(colorW), GUILayout.Height(colorH))) { PlayerData.cacheColorName = ((int)Random.Range(9999, 999999)).ToString(); PlayerData.SetColor(PlayerData.cacheColorName, couleur.colors[variation]); inspector.paleting = 2; this.Close(); } palette.colors[i] = couleur; GUI.backgroundColor = c; GUILayout.EndVertical(); } else { GUILayout.BeginVertical(); GUILayout.Label("NEW", style, GUILayout.Width(colorW)); style = new GUIStyle(GUI.skin.button); style.fontSize = 35; style.alignment = TextAnchor.MiddleCenter; GUI.contentColor = Color.white; if (GUILayout.Button("+", style, GUILayout.Width(colorW), GUILayout.Height(colorH))) { palette.colors.Add(new Couleur("color")); } GUILayout.EndVertical(); } x += 1; } GUILayout.EndHorizontal(); GUI.contentColor = gc; palette.variation = (int)GUING.Slider(palette.variation, 0, 5, 1, new Vector2(0, 0), "Variation " + palette.variation, rect.width * 0.95f); GUING.Line(2, 0.1f); GUILayout.BeginHorizontal(); if (GUILayout.Button("<")) { palette.order--; } style = new GUIStyle(GUI.skin.label); style.fontSize = 8; style.alignment = TextAnchor.MiddleCenter; GUILayout.Label((-palette.order).ToString(), style, GUILayout.Width(50)); if (GUILayout.Button(">")) { palette.order++; } GUILayout.EndHorizontal(); GUILayout.EndArea(); }