private void closeSectionGUI() { sectionData = null; editingColor = new RecoloringData(Color.white, 0, 0); rStr = gStr = bStr = aStr = "255"; colorIndex = 0; }
public RecoloringData(RecoloringData data) { color = data.color; specular = data.specular; metallic = data.metallic; detail = data.detail; }
public readonly int featureMask; //1 = color, 2 = specular, 4 = metallic, 8 = hardness public TextureSet(ConfigNode node) { name = node.GetStringValue("name"); title = node.GetStringValue("title", name); ConfigNode[] texNodes = node.GetNodes("TEXTURE"); int len = texNodes.Length; textureData = new TextureSetMaterialData[len]; for (int i = 0; i < len; i++) { textureData[i] = new TextureSetMaterialData(texNodes[i]); } supportsRecoloring = node.GetBoolValue("recolorable", false); recolorableChannelMask = node.GetIntValue("channelMask", 1 | 2 | 4); featureMask = node.GetIntValue("featureMask", 1 | 2 | 4); if (node.HasNode("COLORS")) { ConfigNode colorsNode = node.GetNode("COLORS"); RecoloringData c1 = new RecoloringData(colorsNode.GetStringValue("mainColor")); RecoloringData c2 = new RecoloringData(colorsNode.GetStringValue("secondColor")); RecoloringData c3 = new RecoloringData(colorsNode.GetStringValue("detailColor")); maskColors = new RecoloringData[] { c1, c2, c3 }; } else { maskColors = new RecoloringData[3]; Color white = Color.white; maskColors[0] = new RecoloringData(white, 0, 0); maskColors[1] = new RecoloringData(white, 0, 0); maskColors[2] = new RecoloringData(white, 0, 0); } }
/// <summary> /// /// </summary> /// <param name="node"></param> /// <param name="defaultMode"></param> public TextureSet(ConfigNode node, string defaultMode) { name = node.GetStringValue("name"); title = node.GetStringValue("title", name); ConfigNode[] texNodes = node.GetNodes("MATERIAL"); int len = texNodes.Length; if (len == 0) { Log.log("Did not find any MATERIAL nodes in texture set:" + name + ", searching for legacy styled TEXTURE nodes."); Log.log("Please update the config for the texture-set to fix this error."); texNodes = node.GetNodes("TEXTURE"); len = texNodes.Length; } textureData = new TextureSetMaterialData[len]; for (int i = 0; i < len; i++) { textureData[i] = new TextureSetMaterialData(this, texNodes[i], defaultMode); } supportsRecoloring = node.GetBoolValue("recolorable", false); recolorableChannelMask = node.GetIntValue("channelMask", 1 | 2 | 4); featureMask = node.GetIntValue("featureMask", 1 | 2 | 4); if (node.HasNode("COLORS")) { ConfigNode colorsNode = node.GetNode("COLORS"); RecoloringData c1 = RecoloringData.ParseColorsBlockEntry(colorsNode.GetStringValue("mainColor")); RecoloringData c2 = RecoloringData.ParseColorsBlockEntry(colorsNode.GetStringValue("secondColor")); RecoloringData c3 = RecoloringData.ParseColorsBlockEntry(colorsNode.GetStringValue("detailColor")); maskColors = new RecoloringData[] { c1, c2, c3 }; } else { maskColors = new RecoloringData[3]; Color white = PresetColor.getColor("white").color;//will always return -something-, even if 'white' is undefined maskColors[0] = new RecoloringData(white, 0, 0, 1); maskColors[1] = new RecoloringData(white, 0, 0, 1); maskColors[2] = new RecoloringData(white, 0, 0, 1); } //loop through materials, and auto-enable 'recoloring' flag if recoloring keyword is set len = textureData.Length; for (int i = 0; i < len; i++) { int len2 = textureData[i].shaderProperties.Length; for (int k = 0; k < len2; k++) { if (textureData[i].shaderProperties[k].name == "TU_RECOLOR") { supportsRecoloring = true; } } } }
private void drawPresetColorArea() { if (sectionData == null) { return; } GUILayout.Label("Select a preset color: "); presetColorScrollPos = GUILayout.BeginScrollView(presetColorScrollPos, false, true); bool update = false; Color old = GUI.color; Color guiColor = old; List <RecoloringDataPreset> presetColors = PresetColor.getColorList(groupName); int len = presetColors.Count; GUILayout.BeginHorizontal(); for (int i = 0; i < len; i++) { if (i > 0 && i % 2 == 0) { GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); } GUILayout.Label(presetColors[i].title, nonWrappingLabelStyle, GUILayout.Width(115)); guiColor = presetColors[i].color; guiColor.a = 1f; GUI.color = guiColor; if (GUILayout.Button("Select", GUILayout.Width(55))) { editingColor = presetColors[i].getRecoloringData(); rStr = (editingColor.color.r * 255f).ToString("F0"); gStr = (editingColor.color.g * 255f).ToString("F0"); bStr = (editingColor.color.b * 255f).ToString("F0"); aStr = (editingColor.specular * 255f).ToString("F0"); mStr = (editingColor.metallic * 255f).ToString("F0"); //dStr = (editingColor.detail * 100f).ToString("F0");//leave detail mult as pre-specified value (user/config); it does not pull from preset colors at all update = true; } GUI.color = old; } GUILayout.EndHorizontal(); GUILayout.EndScrollView(); GUI.color = old; if (sectionData.colors != null) { sectionData.colors[colorIndex] = editingColor; if (update) { sectionData.updateColors(); } } }
private void setupSectionData(SectionRecolorData section, int colorIndex) { this.sectionData = section; this.colorIndex = colorIndex; if (section.colors == null) { return; } editingColor = sectionData.colors[colorIndex]; rStr = (editingColor.color.r * 255f).ToString("F0"); gStr = (editingColor.color.g * 255f).ToString("F0"); bStr = (editingColor.color.b * 255f).ToString("F0"); aStr = (editingColor.specular * 255f).ToString("F0"); mStr = (editingColor.metallic * 255f).ToString("F0"); }
private void loadPersistentData(string data) { if (!string.IsNullOrEmpty(data)) { string[] colorSplits = data.Split(';'); int len = colorSplits.Length; customColors = new RecoloringData[len]; for (int i = 0; i < len; i++) { customColors[i] = RecoloringData.ParsePersistence(colorSplits[i]); } } else { customColors = new RecoloringData[0]; } }
public TextureSet(ConfigNode node) { name = node.GetStringValue("name"); title = node.GetStringValue("title", name); ConfigNode[] texNodes = node.GetNodes("MATERIAL"); int len = texNodes.Length; if (len == 0) { MonoBehaviour.print("Did not find any MATERIAL nodes in texture set:" + name + ", searching for legacy styled TEXTURE nodes."); MonoBehaviour.print("Please update the config for the texture-set to fix this error."); texNodes = node.GetNodes("TEXTURE"); len = texNodes.Length; } textureData = new TextureSetMaterialData[len]; for (int i = 0; i < len; i++) { textureData[i] = new TextureSetMaterialData(texNodes[i]); } supportsRecoloring = node.GetBoolValue("recolorable", false); recolorableChannelMask = node.GetIntValue("channelMask", 1 | 2 | 4); featureMask = node.GetIntValue("featureMask", 1 | 2 | 4); if (node.HasNode("COLORS")) { ConfigNode colorsNode = node.GetNode("COLORS"); RecoloringData c1 = new RecoloringData(colorsNode.GetStringValue("mainColor")); RecoloringData c2 = new RecoloringData(colorsNode.GetStringValue("secondColor")); RecoloringData c3 = new RecoloringData(colorsNode.GetStringValue("detailColor")); maskColors = new RecoloringData[] { c1, c2, c3 }; } else { maskColors = new RecoloringData[3]; Color white = Color.white; maskColors[0] = new RecoloringData(white, 0, 0); maskColors[1] = new RecoloringData(white, 0, 0); maskColors[2] = new RecoloringData(white, 0, 0); } }
public RecoloringHandler(BaseField persistentDataField) { this.persistentDataField = persistentDataField; int len = 3; colorData = new RecoloringData[len]; string data = this.persistentDataField.GetValue <string>(persistentDataField.host); if (string.IsNullOrEmpty(data)) { for (int i = 0; i < len; i++) { colorData[i] = new RecoloringData(Color.white, 0, 0, 1); } } else { string[] channelData = data.Split(';'); for (int i = 0; i < len; i++) { colorData[i] = RecoloringData.ParsePersistence(channelData[i]); } } }
private void drawSectionRecoloringArea() { if (sectionData == null) { return; } bool updated = false; GUILayout.BeginHorizontal(); GUILayout.Label("Editing: ", GUILayout.Width(60)); GUILayout.Label(sectionData.sectionName); GUILayout.Label(getSectionLabel(colorIndex) + " Color"); GUILayout.FlexibleSpace();//to force everything to the left instead of randomly spaced out, while still allowing dynamic length adjustments GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (drawColorInputLine("Red", ref editingColor.color.r, ref rStr, sectionData.colorSupported())) { updated = true; } if (GUILayout.Button("Load Pattern", GUILayout.Width(120))) { sectionData.colors[0] = storedPattern[0]; sectionData.colors[1] = storedPattern[1]; sectionData.colors[2] = storedPattern[2]; editingColor = sectionData.colors[colorIndex]; updated = true; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (drawColorInputLine("Green", ref editingColor.color.g, ref gStr, sectionData.colorSupported())) { updated = true; } if (GUILayout.Button("Store Pattern", GUILayout.Width(120))) { storedPattern = new RecoloringData[3]; storedPattern[0] = sectionData.colors[0]; storedPattern[1] = sectionData.colors[1]; storedPattern[2] = sectionData.colors[2]; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (drawColorInputLine("Blue", ref editingColor.color.b, ref bStr, sectionData.colorSupported())) { updated = true; } if (GUILayout.Button("Load Color", GUILayout.Width(120))) { editingColor = storedColor; updated = true; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (drawColorInputLine("Specular", ref editingColor.specular, ref aStr, sectionData.specularSupported())) { updated = true; } if (GUILayout.Button("Store Color", GUILayout.Width(120))) { storedColor = editingColor; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (sectionData.metallicSupported()) { if (drawColorInputLine("Metallic", ref editingColor.metallic, ref mStr, true)) { updated = true; } } else if (sectionData.hardnessSupported()) { if (drawColorInputLine("Hardness", ref editingColor.metallic, ref mStr, true)) { updated = true; } } else { if (drawColorInputLine("Metallic", ref editingColor.metallic, ref mStr, false)) { updated = true; } } GUILayout.EndHorizontal(); if (updated) { sectionData.colors[colorIndex] = editingColor; sectionData.updateColors(); } }
private void drawSectionRecoloringArea() { if (sectionData == null) { return; } bool updated = false; GUILayout.BeginHorizontal(); GUILayout.Label("Editing: ", GUILayout.Width(60)); GUILayout.Label(sectionData.sectionName); GUILayout.Label(getSectionLabel(colorIndex) + " Color"); GUILayout.FlexibleSpace();//to force everything to the left instead of randomly spaced out, while still allowing dynamic length adjustments GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (drawColorInputLine("Red", ref editingColor.color.r, ref rStr, sectionData.colorSupported(), 255, 1)) { updated = true; } if (GUILayout.Button("Load Pattern", GUILayout.Width(120))) { sectionData.colors[0] = storedPattern[0]; sectionData.colors[1] = storedPattern[1]; sectionData.colors[2] = storedPattern[2]; editingColor = sectionData.colors[colorIndex]; updated = true; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (drawColorInputLine("Green", ref editingColor.color.g, ref gStr, sectionData.colorSupported(), 255, 1)) { updated = true; } if (GUILayout.Button("Store Pattern", GUILayout.Width(120))) { storedPattern = new RecoloringData[3]; storedPattern[0] = sectionData.colors[0]; storedPattern[1] = sectionData.colors[1]; storedPattern[2] = sectionData.colors[2]; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (drawColorInputLine("Blue", ref editingColor.color.b, ref bStr, sectionData.colorSupported(), 255, 1)) { updated = true; } if (GUILayout.Button("Load Color", GUILayout.Width(120))) { editingColor = storedColor; updated = true; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (drawColorInputLine("Specular", ref editingColor.specular, ref aStr, sectionData.specularSupported(), 255, 1)) { updated = true; } if (GUILayout.Button("Store Color", GUILayout.Width(120))) { storedColor = editingColor; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (sectionData.metallicSupported()) { if (drawColorInputLine("Metallic", ref editingColor.metallic, ref mStr, true, 255, 1)) { updated = true; } } else if (sectionData.hardnessSupported()) { if (drawColorInputLine("Hardness", ref editingColor.metallic, ref mStr, true, 255, 1)) { updated = true; } } else { if (drawColorInputLine("Metallic", ref editingColor.metallic, ref mStr, false, 255, 1)) { updated = true; } } if (GUILayout.Button("<", GUILayout.Width(20))) { groupIndex--; List <RecoloringDataPresetGroup> gs = PresetColor.getGroupList(); if (groupIndex < 0) { groupIndex = gs.Count - 1; } groupName = gs[groupIndex].name; } GUILayout.Label("Palette", GUILayout.Width(70)); if (GUILayout.Button(">", GUILayout.Width(20))) { groupIndex++; List <RecoloringDataPresetGroup> gs = PresetColor.getGroupList(); if (groupIndex >= gs.Count) { groupIndex = 0; } groupName = gs[groupIndex].name; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (drawColorInputLine("Detail %", ref editingColor.detail, ref dStr, true, 100, 5)) { updated = true; } GUILayout.Label(groupName, GUILayout.Width(120)); GUILayout.EndHorizontal(); if (updated) { sectionData.colors[colorIndex] = editingColor; sectionData.updateColors(); } }