private bool GUIMask(string label, string tooltip, string maskKeyword, string channelKeyword, string feature = null, bool enabled = true, bool increaseIndentLevel = false, bool visible = true, string helpTopic = null) { string[] labelsAndKeywords = new string[] { "Off|", "Main Texture|mainTex", "Mask 1|mask1", "Mask 2|mask2", "Mask 3|mask3" }; if (!enabled) { GUI.enabled = false; } if (increaseIndentLevel) { label = "▪ " + label; } string[] labels = new string[labelsAndKeywords.Length]; string[] masks = new string[labelsAndKeywords.Length]; string[] uvs = new string[] { "Main Tex UV", "Independent UV" }; for (int i = 0; i < labelsAndKeywords.Length; i++) { string[] data = labelsAndKeywords[i].Split('|'); labels[i] = data[0]; masks[i] = data[1]; } int curMask = System.Array.IndexOf(masks, TCP2_ShaderGeneratorUtils.GetKeyword(mCurrentConfig, maskKeyword)); if (curMask < 0) { curMask = 0; } TCP2_Utils.TextureChannel curChannel = TCP2_Utils.FromShader(TCP2_ShaderGeneratorUtils.GetKeyword(mCurrentConfig, channelKeyword)); if (curMask <= 1) { curChannel = TCP2_Utils.TextureChannel.Alpha; } string uvKey = (curMask > 1) ? "UV_" + masks[curMask] : null; int curUv = System.Array.IndexOf(uvs, TCP2_ShaderGeneratorUtils.GetKeyword(mCurrentConfig, uvKey)); if (curUv < 0) { curUv = 0; } if (mHideDisabled) { visible = enabled; } if (visible) { EditorGUILayout.BeginHorizontal(); float w = 166; if (!string.IsNullOrEmpty(helpTopic)) { w -= 20; TCP2_GUI.HelpButton(label.TrimStart('▪', ' '), helpTopic); } TCP2_GUI.SubHeader(label, tooltip, (curMask > 0) && enabled, w); curMask = EditorGUILayout.Popup(curMask, labels); GUI.enabled = curMask > 1; curChannel = (TCP2_Utils.TextureChannel)EditorGUILayout.EnumPopup(curChannel); curUv = EditorGUILayout.Popup(curUv, uvs); GUI.enabled = mGUIEnabled; TCP2_GUI.HelpButton("Masks"); EditorGUILayout.EndHorizontal(); } TCP2_ShaderGeneratorUtils.SetKeyword(mCurrentConfig.Keywords, maskKeyword, masks[curMask]); if (curMask > 0) { TCP2_ShaderGeneratorUtils.SetKeyword(mCurrentConfig.Keywords, channelKeyword, curChannel.ToShader()); } if (curMask > 1 && !string.IsNullOrEmpty(uvKey)) { TCP2_ShaderGeneratorUtils.SetKeyword(mCurrentConfig.Keywords, uvKey, uvs[curUv]); } TCP2_ShaderGeneratorUtils.ToggleSingleFeature(mCurrentConfig.Features, feature, (curMask > 0)); if (!enabled) { GUI.enabled = mGUIEnabled; } return(curMask > 0); }