static protected bool DrawPerTexPopUp(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, Channel channel, GUIContent label, GUIContent[] options) { EditorGUILayout.BeginHorizontal(); bool enabled = PerTexToggle(keywords, keyword); GUI.enabled = enabled; Color c = propData.GetValue(curIdx, pixel); float v = c[(int)channel]; EditorGUI.BeginChangeCheck(); int selected = EditorGUILayout.Popup(label, (int)v, options); if (EditorGUI.EndChangeCheck()) { c [(int)channel] = selected; propData.SetValue(curIdx, pixel, c); } if (GUILayout.Button("All", GUILayout.Width(40))) { for (int i = 0; i < 32; ++i) { Color nv = propData.GetValue(i, pixel); nv[(int)channel] = selected; propData.SetValue(i, pixel, nv); } } GUI.enabled = true; drawPertexToggle = true; EditorGUILayout.EndHorizontal(); return(enabled); }
static protected bool DrawPerTexVector2(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, V2Cannel channel, GUIContent label) { EditorGUILayout.BeginHorizontal(); bool enabled = PerTexToggle(keywords, keyword); GUI.enabled = enabled; Color c = propData.GetValue(curIdx, pixel); Vector2 v2 = new Vector2(c.r, c.g); if (channel == V2Cannel.BA) { v2.x = c.b; v2.y = c.a; } Vector2 nv = v2; nv = EditorGUILayout.Vector2Field(label, v2); if (nv != v2) { if (channel == V2Cannel.RG) { c.r = nv.x; c.g = nv.y; } else { c.b = nv.x; c.a = nv.y; } propData.SetValue(curIdx, pixel, c); } if (GUILayout.Button("All", GUILayout.Width(40))) { for (int i = 0; i < 32; ++i) { // don't erase other pixels.. var fv = propData.GetValue(i, pixel); if (channel == V2Cannel.RG) { c.r = nv.x; c.g = nv.y; } else { c.b = nv.x; c.a = nv.y; } propData.SetValue(i, pixel, fv); } } GUI.enabled = true; EditorGUILayout.EndHorizontal(); return(enabled); }
static protected bool DrawPerTexVector3(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, GUIContent label) { EditorGUILayout.BeginHorizontal(); bool enabled = PerTexToggle(keywords, keyword); GUI.enabled = enabled; Color c = propData.GetValue(curIdx, pixel); Vector3 v = new Vector3(c.r, c.g, c.b); Vector3 nv = EditorGUILayout.Vector2Field(label, v); if (nv != v) { c.r = nv.x; c.g = nv.y; c.b = nv.z; propData.SetValue(curIdx, pixel, c); } if (GUILayout.Button("All", GUILayout.Width(40))) { for (int i = 0; i < 32; ++i) { // don't erase other pixels.. var fv = propData.GetValue(i, pixel); c.r = nv.x; c.g = nv.y; c.b = nv.z; propData.SetValue(i, pixel, fv); } } GUI.enabled = true; EditorGUILayout.EndHorizontal(); return(enabled); }
protected bool DrawPerTexColor(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, GUIContent label, bool hasAlpha) { EditorGUILayout.BeginHorizontal(); bool enabled = PerTexToggle(keywords, keyword); GUI.enabled = enabled; Color c = propData.GetValue(curIdx, pixel); Color nv = EditorGUILayout.ColorField(label, c); if (nv != c) { if (!hasAlpha) { nv.a = c.a; } propData.SetValue(curIdx, pixel, nv); } if (GUILayout.Button("All", GUILayout.Width(40))) { for (int i = 0; i < 32; ++i) { if (!hasAlpha) { nv.a = propData.GetValue(i, pixel).a; } propData.SetValue(i, pixel, nv); } } GUI.enabled = true; EditorGUILayout.EndHorizontal(); return(enabled); }
static protected bool DrawPerTexFloatSlider(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, Channel channel, GUIContent label, float min = 0, float max = 0, bool showHeader = true) { EditorGUILayout.BeginHorizontal(); bool enabled = keywords.IsKeywordEnabled(keyword); if (showHeader) { enabled = PerTexToggle(keywords, keyword); GUI.enabled = enabled; } else { EditorGUILayout.LabelField("", GUILayout.Width(20)); GUI.enabled = enabled; } Color c = propData.GetValue(curIdx, pixel); float v = c[(int)channel]; float nv = v; if (min != max) { nv = EditorGUILayout.Slider(label, v, min, max); } else { nv = EditorGUILayout.FloatField(label, v); } if (nv != v) { c[(int)channel] = nv; propData.SetValue(curIdx, pixel, c); } if (GUILayout.Button("All", GUILayout.Width(40))) { for (int i = 0; i < 32; ++i) { propData.SetValue(i, pixel, (int)channel, nv); } } GUI.enabled = true; EditorGUILayout.EndHorizontal(); return(enabled); }
static protected void InitPropData(int pixel, MicroSplatPropData propData, Color defaultValues) { if (propData == null) { return; } // we reserve the last row of potential values as an initialization bit. if (propData.GetValue(pixel, 15) == new Color(0, 0, 0, 0)) { for (int i = 0; i < 32; ++i) { propData.SetValue(i, pixel, defaultValues); } propData.SetValue(pixel, 15, Color.white); } }
static protected bool DrawPerTexVector2Vector2(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, GUIContent label, GUIContent label2) { EditorGUILayout.BeginHorizontal(); bool enabled = PerTexToggle(keywords, keyword); GUI.enabled = enabled; Color c = propData.GetValue(curIdx, pixel); Vector2 v1 = new Vector2(c.r, c.g); Vector2 v2 = new Vector2(c.b, c.a); Vector2 nv1 = v1; Vector2 nv2 = v2; EditorGUILayout.BeginVertical(); nv1 = EditorGUILayout.Vector2Field(label, v1); nv2 = EditorGUILayout.Vector2Field(label2, v2); EditorGUILayout.EndVertical(); if (nv1 != v1 || nv2 != v2) { c.r = nv1.x; c.g = nv1.y; c.b = nv2.x; c.a = nv2.y; propData.SetValue(curIdx, pixel, c); } if (GUILayout.Button("All", GUILayout.Width(40))) { c.r = nv1.x; c.g = nv1.y; c.b = nv2.x; c.a = nv2.y; for (int i = 0; i < 32; ++i) { propData.SetValue(i, pixel, c); } } GUI.enabled = true; EditorGUILayout.EndHorizontal(); return(enabled); }
static protected void DrawPerTexColorNoToggle(int curIdx, int pixel, MicroSplatPropData propData, GUIContent label) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.Width(20)); Color c = propData.GetValue(curIdx, pixel); Color nv = EditorGUILayout.ColorField(label, c); if (nv != c) { propData.SetValue(curIdx, pixel, nv); } if (GUILayout.Button("All", GUILayout.Width(40))) { for (int i = 0; i < 32; ++i) { propData.SetValue(i, pixel, nv); } } EditorGUILayout.EndHorizontal(); drawPertexToggle = true; }
static protected bool DrawPerTexPopUp(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, Channel channel, GUIContent label, GUIContent[] options, float[] values) { EditorGUILayout.BeginHorizontal(); bool enabled = PerTexToggle(keywords, keyword); GUI.enabled = enabled; Color c = propData.GetValue(curIdx, pixel); float v = c[(int)channel]; int selected = -1; if (values.Length == 0 || options.Length == 0) { selected = -1; } else if (options.Length == 1 || values.Length == 1 || values[0] >= v) { selected = 0; } else if (values[values.Length - 1] < v) { selected = values.Length - 1; } else { int length = options.Length < values.Length ? options.Length : values.Length; float dist = -1f; for (int i = 0; i < length; i++) { if (values[i] == v) { selected = i; break; } else { float diff = Mathf.Abs(values[i] - v); if (dist < 0) { dist = diff; selected = i; } else if (diff < dist) { dist = diff; selected = i; } } } } selected = EditorGUILayout.Popup(label, selected, options); v = selected >= 0 ? values[selected] : 0; c[(int)channel] = v; propData.SetValue(curIdx, pixel, c); if (GUILayout.Button("All", GUILayout.Width(40))) { for (int i = 0; i < 32; ++i) { Color nv = propData.GetValue(i, pixel); nv[(int)channel] = v; propData.SetValue(i, pixel, nv); } } GUI.enabled = true; drawPertexToggle = true; EditorGUILayout.EndHorizontal(); return(enabled); }