private static bool EmptyList(DecalGroup grp) { return(grp.decals.Count < 1); }
void DrawSettings(Rect r) { List <string> selected_textures = new List <string>(); foreach (KeyValuePair <int, List <int> > kvp in selected) { foreach (int n in kvp.Value) { selected_textures.Add(decalGroups[kvp.Key].decals[n].texture.name); } } GUI.backgroundColor = SettingsBackgroundColor; GUI.Box(r, "", backgroundColorStyle); GUI.backgroundColor = HeaderBarColor; GUI.Box(new Rect(r.x, r.y, r.width, 22), "", backgroundColorStyle); GUI.Label(new Rect(r.x + 4, r.y + 4, r.width, 22), decalView == DecalView.Atlas ? "Atlas Packing Settings" : "Decal Settings", colorTextStyleBold); if (selected_textures.Count > 0 && decalView == DecalView.Organizational) { GUI.Label(new Rect(r.x + 96, r.y + 4, r.width, 22), (selected_textures.Count > 1 ? selected_textures.Count + " selected." : selected_textures[0]), colorTextStyle); } GUI.backgroundColor = Color.white; bool packed = false; GUI.BeginGroup(r); if (!isFloating) { GUILayout.Space(6); } GUI.enabled = selected.Count > 0; if (decalView == DecalView.Organizational) { Placement rotate_placement = Placement.Fixed; Placement scale_placement = Placement.Fixed; Vector3 rotation = Vector3.zero; Vector3 scale = Vector3.zero; int t = 0; bool[] mixedValue_rotation = new bool[] { false, false, false }, mixedValue_scale = new bool[] { false, false, false }; bool mixedValue_placement_rotation = false; bool mixedValue_placement_scale = false; foreach (KeyValuePair <int, List <int> > kvp in selected) { foreach (int n in kvp.Value) { Placement oldRotationPlacement = rotate_placement; Placement oldScalePlacement = scale_placement; Vector3 oldScale = scale; Vector3 oldRotation = rotation; rotate_placement = decalGroups[kvp.Key].decals[n].rotationPlacement; scale_placement = decalGroups[kvp.Key].decals[n].scalePlacement; rotation = decalGroups[kvp.Key].decals[n].rotation; scale = decalGroups[kvp.Key].decals[n].scale; if (t != 0) { if (rotate_placement != oldRotationPlacement) { mixedValue_placement_rotation = true; } if (scale_placement != oldScalePlacement) { mixedValue_placement_scale = true; } if (oldRotation.x != rotation.x) { mixedValue_rotation[0] = true; } if (oldRotation.y != rotation.y) { mixedValue_rotation[1] = true; } if (oldRotation.z != rotation.z) { mixedValue_rotation[2] = true; } if (oldScale.x != scale.x) { mixedValue_scale[0] = true; } if (oldScale.y != scale.y) { mixedValue_scale[1] = true; } if (oldScale.z != scale.z) { mixedValue_scale[2] = true; } } t++; } } ///*** Rotation ****/// { GUI.enabled = t > 0 && !mixedValue_rotation[0]; minVal = rotation.x; maxVal = rotation.y; defaultVal = rotation.z; // GUILayout.Label("Rotation: " + minVal.ToString("F2") + " to " + maxVal.ToString("F2")); // GUI.enabled = prev; GUILayout.BeginHorizontal(); GUILayout.Label("Rotation", GUILayout.MaxWidth(60)); EditorGUI.showMixedValue = mixedValue_placement_rotation; EditorGUI.BeginChangeCheck(); rotate_placement = (Placement)EditorGUILayout.EnumPopup(rotate_placement, GUILayout.MaxWidth(120)); if (EditorGUI.EndChangeCheck()) { foreach (KeyValuePair <int, List <int> > kvp in selected) { foreach (int i in kvp.Value) { decalGroups[kvp.Key].decals[i].rotationPlacement = rotate_placement; } } } { GUI.enabled = rotate_placement == Placement.Fixed; GUILayout.Label("Default", GUILayout.MaxWidth(46)); EditorGUI.showMixedValue = mixedValue_rotation[2]; EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("RotationDefaultValue"); defaultVal = EditorGUILayout.FloatField(defaultVal, GUILayout.MaxWidth(44)); if (EditorGUI.EndChangeCheck()) { foreach (KeyValuePair <int, List <int> > kvp in selected) { foreach (int i in kvp.Value) { decalGroups[kvp.Key].decals[i].rotation.z = defaultVal; } } } } // else { GUILayout.Space(5); GUI.enabled = rotate_placement == Placement.Random; EditorGUI.showMixedValue = mixedValue_rotation[0]; EditorGUI.BeginChangeCheck(); GUILayout.Label("Min", GUILayout.MaxWidth(30)); GUI.SetNextControlName("RotationMinValue"); minVal = EditorGUILayout.FloatField(minVal, GUILayout.MaxWidth(44)); if (EditorGUI.EndChangeCheck()) { foreach (KeyValuePair <int, List <int> > kvp in selected) { foreach (int i in kvp.Value) { decalGroups[kvp.Key].decals[i].rotation.x = minVal; } } } EditorGUI.showMixedValue = mixedValue_rotation[1]; EditorGUI.BeginChangeCheck(); GUILayout.Label("Max", GUILayout.MaxWidth(30)); GUI.SetNextControlName("RotationMaxValue"); maxVal = EditorGUILayout.FloatField(maxVal, GUILayout.MaxWidth(44)); if (EditorGUI.EndChangeCheck()) { foreach (KeyValuePair <int, List <int> > kvp in selected) { foreach (int i in kvp.Value) { decalGroups[kvp.Key].decals[i].rotation.y = maxVal; } } } } GUILayout.EndHorizontal(); } ///*** Rotation ****/// GUILayout.Space(8); ///*** Scale ****/// { GUI.enabled = t > 0 && !mixedValue_rotation[0]; minVal = scale.x; maxVal = scale.y; defaultVal = scale.z; GUILayout.BeginHorizontal(); GUILayout.Label("Scale", GUILayout.MaxWidth(60)); EditorGUI.showMixedValue = mixedValue_placement_scale; EditorGUI.BeginChangeCheck(); scale_placement = (Placement)EditorGUILayout.EnumPopup(scale_placement, GUILayout.MaxWidth(120)); if (EditorGUI.EndChangeCheck()) { foreach (KeyValuePair <int, List <int> > kvp in selected) { foreach (int i in kvp.Value) { decalGroups[kvp.Key].decals[i].scalePlacement = scale_placement; } } } { GUI.enabled = scale_placement == Placement.Fixed; GUILayout.Label("Default", GUILayout.MaxWidth(46)); EditorGUI.showMixedValue = mixedValue_scale[2]; EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("ScaleDefaultValue"); defaultVal = EditorGUILayout.FloatField(defaultVal, GUILayout.MaxWidth(44)); if (EditorGUI.EndChangeCheck()) { foreach (KeyValuePair <int, List <int> > kvp in selected) { foreach (int i in kvp.Value) { decalGroups[kvp.Key].decals[i].scale.z = defaultVal; } } } } // else { GUILayout.Space(5); GUI.enabled = scale_placement == Placement.Random; EditorGUI.showMixedValue = mixedValue_scale[0]; EditorGUI.BeginChangeCheck(); GUILayout.Label("Min", GUILayout.MaxWidth(30)); GUI.SetNextControlName("ScaleMinValue"); minVal = EditorGUILayout.FloatField(minVal, GUILayout.MaxWidth(44)); if (EditorGUI.EndChangeCheck()) { foreach (KeyValuePair <int, List <int> > kvp in selected) { foreach (int i in kvp.Value) { decalGroups[kvp.Key].decals[i].scale.x = minVal; } } } EditorGUI.showMixedValue = mixedValue_scale[1]; EditorGUI.BeginChangeCheck(); GUILayout.Label("Max", GUILayout.MaxWidth(30)); GUI.SetNextControlName("ScaleMaxValue"); maxVal = EditorGUILayout.FloatField(maxVal, GUILayout.MaxWidth(44)); if (EditorGUI.EndChangeCheck()) { foreach (KeyValuePair <int, List <int> > kvp in selected) { foreach (int i in kvp.Value) { decalGroups[kvp.Key].decals[i].scale.y = maxVal; } } } } GUILayout.EndHorizontal(); } ///*** Scale ****/// GUI.enabled = true; EditorGUI.showMixedValue = false; } // organizational view else { #if UNITY_WEBPLAYER GUI.enabled = false; #endif /* ATLAS VIEW */ Material mat = null; int key = -1; // Material and packing info if (selected.Count > 0) { key = selected.First().Key; DecalGroup decalGroup = decalGroups[key]; packed = decalGroup.isPacked && decalGroup.material != null; mat = decalGroup.material; } GUI.enabled = false; EditorGUILayout.ObjectField("Group Material", mat, typeof(Material), false, GUILayout.MaxWidth(r.width - 10)); #if !UNITY_WEBPLAYER GUI.enabled = true; #endif ///*** Group Name ***/// { EditorGUI.showMixedValue = selected.Count != 1; if (key > -1) { name = decalGroups[key].name; } EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("GroupName"); if (selected.Count == 1) { name = EditorGUILayout.TextField("Name", name); } else { EditorGUILayout.TextField("Name", name); } if (EditorGUI.EndChangeCheck() && selected.Count == 1) { decalGroups[key].name = name; } } ///*** PackTextures settings padding ***/// { int pad = selected.Count == 1 ? decalGroups[key].padding : 4; EditorGUI.BeginChangeCheck(); if (selected.Count == 1) { pad = EditorGUILayout.IntSlider("Padding", pad, 0, 12); } else { EditorGUILayout.IntSlider("Padding", pad, 0, 12); } if (EditorGUI.EndChangeCheck()) { foreach (KeyValuePair <int, List <int> > kvp in selected) { decalGroups[kvp.Key].padding = pad; decalGroups[kvp.Key].isPacked = false; } } } } EditorGUI.showMixedValue = false; GUI.enabled = true; GUI.EndGroup(); if (decalView == DecalView.Atlas) { #if UNITY_WEBPLAYER GUI.enabled = false; #else GUI.enabled = !packed; #endif Color bg = GUI.backgroundColor; if (selected.Count > 0) { GUI.backgroundColor = !packed ? PackedRed : Color.green; } if (GUI.Button(new Rect((r.x + r.width) - 120, r.y + 2, 116, 17), new GUIContent((!packed ? "Pack Decals" : "Atlased"), "When a decal is selected, this button will show green for a packed group atlas and red if not packed. When no decals are selected, clicking \"Pack Decals\" will atlas all groups that are not already packed."))) { if (selected.Count > 0) { foreach (KeyValuePair <int, List <int> > kvp in selected) { if (!decalGroups[kvp.Key].isPacked || decalGroups[kvp.Key].material == null) { database.PackTextures(kvp.Key); qdUtil.RefreshSceneDecals(decalGroups[kvp.Key]); } } } else { for (int i = 0; i < decalGroups.Count; i++) { if (!decalGroups[i].isPacked || decalGroups[i].material == null) { database.PackTextures(i); qdUtil.RefreshSceneDecals(decalGroups[i]); } } } } GUI.backgroundColor = bg; } }