예제 #1
0
 private void TryDrawAlphaCheckBg(Rect position, HsvLookup id)
 {
     if (id == HsvLookup.A && Event.current.type == EventType.Repaint)
     {
         Rect uvLayout = new Rect
         {
             width  = position.width / position.height,                    // texture aspect is 1:1
             height = 1f
         };
         Graphics.DrawTexture(position, k_alphaSliderCheckerBackground, uvLayout, 0, 0, 0, 0);
     }
 }
예제 #2
0
        private bool TryUpdateHsvLookup(SerializedProperty property, string name, HsvLookup id)
        {
            SerializedProperty minProp = property.FindPropertyRelative($"{name}Min");
            SerializedProperty maxProp = property.FindPropertyRelative($"{name}Max");

            if (m_hsvLookup.TryGetValue(id, out MinMaxPair pair))
            {
                pair.Min = minProp.floatValue;
                pair.Max = maxProp.floatValue;
                return(true);
            }
            else
            {
                m_hsvLookup[id] = new MinMaxPair(name, minProp.floatValue, maxProp.floatValue);
                return(false);
            }
        }
예제 #3
0
        private void DrawHsvProperty(
            ref Rect position, SerializedProperty property, HsvLookup id, Texture2D hsvTexture,
            int width, float hue, float saturation, ref float oldHue, ref float oldSaturation
            )
        {
            MinMaxPair pair = GetHsvProperty(id);

            if (m_hsvStyle == null)
            {
                m_hsvStyle = new GUIStyle(EditorStyles.label);
            }

            position.y += position.height;
            position.y += EditorGUIUtility.singleLineHeight / 2f;

            using (var check = new EditorGUI.ChangeCheckScope())
            {
                Rect texPos = new Rect(position);
                texPos.y     -= EditorGUIUtility.singleLineHeight / 2f;
                texPos.x     += EditorGUIUtility.labelWidth + 1;
                texPos.width -= EditorGUIUtility.labelWidth - 1;

                TryDrawAlphaCheckBg(texPos, id);

                hsvTexture = Update1DSlider(hsvTexture, width, hue, saturation, ref oldHue, ref oldSaturation, (int)id, id != HsvLookup.A);
                m_hsvStyle.normal.background = hsvTexture;

                GUI.Box(texPos, GUIContent.none, m_hsvStyle);
                EditorGUI.MinMaxSlider(position, pair.Name, ref pair.Min, ref pair.Max, k_minSaturation, 1);

                if (check.changed)
                {
                    OnColorChanged(property, pair);
                }
            }
        }
예제 #4
0
 private MinMaxPair GetHsvProperty(HsvLookup lookup)
 {
     return(m_hsvLookup[lookup]);
 }