public override void OnInspectorGUI() { this.script = target as PoolingData; DrawDefaultInspector(); EditorGUILayout.Space(); if (GUILayout.Button("ADD NEW POOL")) { script.AddAt(script.pools.Count); } if (GUILayout.Button("REMOVE ALL POOLS")) { script.pools.Clear(); } Rect rect = EditorGUILayout.GetControlRect(true, 0); Rect baserect = rect; EditorGUILayoutExtension.DragAndDropField(635, "", false, this.OnDrag, this.Rules); if (script.pools.Count == 0) { return; } baserect.y += 9; baserect.width = 50; baserect.height = 20; EditorGUI.LabelField(baserect, "Pool", EditorStyles.boldLabel); // Rect n = rect; // n.x += 30; // n.y += 450; // n.width = 200; // n.height = 20; // val = EditorGUI.FloatField(n, "Value", val); GUIStyle style = new GUIStyle(EditorStyles.label); GUIStyle n_style = new GUIStyle(EditorStyles.miniLabel); n_style.fontSize = 8; style.richText = true; PoolingData.Pool pool; baserect.y += 18; for (int i = 0; i < script.pools.Count; ++i) { pool = script.pools[i]; baserect.x = rect.x + -8; baserect.width = rect.width + 7; baserect.height = 21; EditorGUI.DrawRect(baserect, grey); baserect.x += 15; baserect.y += 3; baserect.width = 0; baserect.height = 15; pool.show = EditorGUI.Foldout(baserect, pool.show, ""); baserect.y += -1; baserect.width = 1000; baserect.height = 40; if (pool.prefab) { EditorGUI.LabelField(baserect, pool.prefab.name, style); baserect.x = EditorUtilityExtension.GetTextWidth(pool.prefab.name, EditorStyles.label) + 21; EditorGUI.LabelField(baserect, $"({pool.size})", n_style); } else { EditorGUI.LabelField(baserect, "<color=yellow>Empty</color>", style); } baserect.x = rect.width + -7; baserect.y += 1; baserect.width = 20; baserect.height = 20; if (GUI.Button(baserect, this.plusTexture, GUIStyle.none)) { script.AddAt(i + 1); return; } if (pool.show) { baserect.x = rect.width + -24; baserect.width = 16; baserect.height = 16; if (GUI.Button(baserect, this.trashTexture, GUIStyle.none)) { script.pools.RemoveAt(i); return; } baserect.x = rect.x + -8; baserect.y += 18; baserect.width = rect.width + 7; baserect.height = 46; EditorGUI.DrawRect(baserect, grey); baserect.x += 3; baserect.width += -6; baserect.height += -3; EditorGUI.DrawRect(baserect, dark); baserect.x += 1; baserect.y += 3; baserect.width = rect.width + -2; baserect.height = 17; EditorGUIUtility.labelWidth += -77; pool.prefab = EditorGUI.ObjectField(baserect, "Prefab", pool.prefab, typeof(GameObject), false) as GameObject; EditorGUIUtility.labelWidth += 1; baserect.y += 20; baserect.width = rect.width + -4; baserect.height = 17; pool.size = EditorGUI.IntSlider(baserect, "Size", pool.size, 1, 1000); baserect.y += 5; EditorGUIUtility.labelWidth += 76; } baserect.y += 21; script.pools[i] = pool; } EditorUtilityExtension.SetDirtyOnGUIChange(script); }
// private float val = 0f; public override void OnInspectorGUI() { InteractiveEngine script = target as InteractiveEngine; DrawDefaultInspector(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Elements", EditorStyles.boldLabel); Rect rect = EditorGUILayout.GetControlRect(true, 0); // Rect n = rect; // n.x += 30; // n.y += 600; // n.width = 200; // n.height = 20; // val = EditorGUI.FloatField(n, "Val", val); ChemicalToArrayData e; Rect elementrect = rect; Rect colorrect; if (script.inspector_showDetails == null || script.inspector_showDetails.Length != script.primaries.Count) { script.inspector_showDetails = new bool[script.primaries.Count]; } for (int i = 0; i < script.primaries.Count; ++i) { e = script.primaries[i]; elementrect.x = rect.x + 3; elementrect.width = rect.width + -15; elementrect.height = 22; colorrect = elementrect; colorrect.x += -3; colorrect.y += -3; colorrect.width += 6; colorrect.height += 6; EditorGUI.DrawRect(colorrect, grey); EditorGUI.DrawRect(elementrect, dark); elementrect.x += 18; elementrect.y += 3; elementrect.width = 200; elementrect.height = 20; script.inspector_showDetails[i] = EditorGUI.Foldout(elementrect, script.inspector_showDetails[i], e.element.ToString()); if (script.inspector_showDetails[i]) { elementrect.x += -18; elementrect.y += elementrect.height - 1; elementrect.width = rect.width + -15; elementrect.height = 40; colorrect = elementrect; colorrect.x += -3; colorrect.y += 3; colorrect.width += 6; EditorGUI.DrawRect(colorrect, grey); EditorGUI.DrawRect(elementrect, dark); this.builder.Clear(); this.builder.Append(e.array[0].ToString()); for (int j = 1; j < e.array.Length; ++j) { this.builder.Append(" + ").Append(e.array[j].ToString()); } elementrect.x += 9; elementrect.y += -2; EditorGUI.LabelField(elementrect, "Recipe :", EditorStyles.boldLabel); elementrect.x += 56; EditorGUI.LabelField(elementrect, this.builder.ToString(), EditorStyles.miniLabel); elementrect.x += -56; elementrect.y += 20; EditorGUI.LabelField(elementrect, "Weaknesses :", EditorStyles.boldLabel); ChemicalElement[] weaknesses = script.weaknesses.Find(x => x.element == e.element).array; int index = 0; elementrect.x += 93; elementrect.width = rect.width + -125; bool back = false; do { colorrect = elementrect; this.builder.Clear(); this.builder.Append(weaknesses[index++]); while (index < weaknesses.Length) { if (EditorUtilityExtension.GetTextWidth(this.builder.ToString() + ", " + weaknesses[index], EditorStyles.miniLabel) > elementrect.width) { break; } this.builder.Append(", ").Append(weaknesses[index++]); } if (back) { colorrect.x += -105; colorrect.y += 10; colorrect.width += 116; colorrect.height = 15; EditorGUI.DrawRect(colorrect, grey); colorrect.x += 3; colorrect.y += -3; colorrect.width += -6; colorrect.height = 15; EditorGUI.DrawRect(colorrect, dark); } EditorGUI.LabelField(elementrect, this.builder.ToString(), EditorStyles.miniLabel); elementrect.y += 15; back = true; }while(index < weaknesses.Length); elementrect.y += (i == 0) ? 8 : 10; elementrect.x += -84; } else { elementrect.y += 22; } } if (script.primaries.Count == 0) { elementrect.x += 20; elementrect.y += -5; } elementrect.x += -18; elementrect.y += 5; elementrect.width = rect.width + -15; elementrect.height = 20; if (GUI.Button(elementrect, "WARM UP")) { script.WarmUp(); } }