Exemplo n.º 1
0
 public static Texture2D GetPreview(int previewWidth, int previewHeight, SerializedProperty property, SerializedProperty property2, Color color)
 {
     if (property2 == null)
     {
         return(AnimationCurvePreviewCache.GetPropertyPreview(previewWidth, previewHeight, false, default(Rect), property, color));
     }
     return(AnimationCurvePreviewCache.GetPropertyPreviewRegion(previewWidth, previewHeight, false, default(Rect), property, property2, color));
 }
Exemplo n.º 2
0
 public static Texture2D GetPreview(int previewWidth, int previewHeight, SerializedProperty property, SerializedProperty property2, Color color, Rect curveRanges)
 {
     if (property2 == null)
     {
         return(AnimationCurvePreviewCache.GetPropertyPreview(previewWidth, previewHeight, true, curveRanges, property, color));
     }
     return(AnimationCurvePreviewCache.GetPropertyPreviewRegion(previewWidth, previewHeight, true, curveRanges, property, property2, color));
 }
        public static Texture2D GetPreview(int previewWidth, int previewHeight, SerializedProperty property, SerializedProperty property2, Color color, Color topFillColor, Color bottomFillColor, Rect curveRanges)
        {
            Texture2D result;

            if (property2 == null)
            {
                result = AnimationCurvePreviewCache.GetPropertyPreviewFilled(previewWidth, previewHeight, true, curveRanges, property, color, topFillColor, bottomFillColor);
            }
            else
            {
                result = AnimationCurvePreviewCache.GetPropertyPreviewRegionFilled(previewWidth, previewHeight, true, curveRanges, property, property2, color, topFillColor, bottomFillColor);
            }
            return(result);
        }
 public static Texture2D GetPreview(int previewWidth, int previewHeight, AnimationCurve curve, Color color, Color topFillColor, Color bottomFillColor)
 {
     return(AnimationCurvePreviewCache.GetCurvePreviewFilled(previewWidth, previewHeight, false, default(Rect), curve, color, topFillColor, bottomFillColor));
 }
 public static Texture2D GetPreview(int previewWidth, int previewHeight, AnimationCurve curve, Color color, Rect curveRanges)
 {
     return(AnimationCurvePreviewCache.GetPreview(previewWidth, previewHeight, curve, color, Color.clear, Color.clear, curveRanges));
 }
 public static Texture2D GetPreview(int previewWidth, int previewHeight, AnimationCurve curve, Color color, Color topFillColor, Color bottomFillColor, Rect curveRanges)
 {
     return(AnimationCurvePreviewCache.GetCurvePreviewFilled(previewWidth, previewHeight, true, curveRanges, curve, color, topFillColor, bottomFillColor));
 }
Exemplo n.º 7
0
 public static Texture2D GetPreview(int previewWidth, int previewHeight, AnimationCurve curve, Color color)
 {
     return(AnimationCurvePreviewCache.GetCurvePreview(previewWidth, previewHeight, false, new Rect(), curve, color));
 }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            Init(property);

            Rect fieldRect;
            var  mode = (MinMaxCurveState)m_Property.mode.intValue;

            // Only curves require manually drawing a label, the controls for scalar handle the label drawing themselves.
            if (!m_Property.mode.hasMultipleDifferentValues && (mode == MinMaxCurveState.k_Scalar || mode == MinMaxCurveState.k_TwoScalars))
            {
                fieldRect = position;
            }
            else
            {
                fieldRect = EditorGUI.PrefixLabel(position, label);
            }

            // Mode
            fieldRect.width -= s_Styles.stateButtonWidth;
            var modeRect = new Rect(fieldRect.xMax, fieldRect.y, s_Styles.stateButtonWidth, fieldRect.height);

            EditorGUI.BeginProperty(modeRect, GUIContent.none, m_Property.mode);
            EditorGUI.BeginChangeCheck();
            //GUI.Button(modeRect, "T"); // worrks
            int newSelection = EditorGUI.Popup(modeRect, null, m_Property.mode.intValue, s_Styles.modes, EditorStyles.minMaxStateDropdown);

            if (EditorGUI.EndChangeCheck())
            {
                m_Property.mode.intValue = newSelection;
                InitCurves();
                AnimationCurvePreviewCache.ClearCache();
            }
            EditorGUI.EndProperty();

            if (m_Property.mode.hasMultipleDifferentValues)
            {
                EditorGUI.LabelField(fieldRect, GUIContent.Temp("-"));
                return;
            }

            switch (mode)
            {
            case MinMaxCurveState.k_Scalar:
                EditorGUI.PropertyField(fieldRect, m_Property.constantMax, label);
                break;

            case MinMaxCurveState.k_Curve:
                DoMinMaxCurvesField(fieldRect, m_Property.curveMax.GetHashCode(), m_Property.curveMax, null, m_Property.curveMultiplier, s_Styles.curveColor, s_Styles.curveBackgroundColor);
                break;

            case MinMaxCurveState.k_TwoCurves:
                DoMinMaxCurvesField(fieldRect, m_Property.curveMin.GetHashCode(), m_Property.curveMax, m_Property.curveMin, m_Property.curveMultiplier, s_Styles.curveColor, s_Styles.curveBackgroundColor);
                break;

            case MinMaxCurveState.k_TwoScalars:
                float fieldWidth = (fieldRect.width - EditorGUIUtility.labelWidth) * 0.5f;
                var   rectMin    = new Rect(fieldRect.x, fieldRect.y, fieldRect.width - fieldWidth - (s_Styles.floatFieldDragWidth * 0.5f), fieldRect.height);
                EditorGUI.PropertyField(rectMin, m_Property.constantMin, label);
                var rectMax         = new Rect(rectMin.xMax + s_Styles.floatFieldDragWidth, fieldRect.y, fieldWidth - (s_Styles.floatFieldDragWidth * 0.5f), fieldRect.height);
                var rectMaxDragArea = new Rect(rectMax.xMin - s_Styles.floatFieldDragWidth, fieldRect.y, s_Styles.floatFieldDragWidth, fieldRect.height);
                EditorGUI.BeginProperty(rectMax, GUIContent.none, m_Property.constantMax);
                EditorGUI.BeginChangeCheck();
                float newConstantMax = EditorGUI.DoFloatField(EditorGUI.s_RecycledEditor, rectMax, rectMaxDragArea, m_Property.constantMax.GetHashCode(), m_Property.constantMax.floatValue, "g7", EditorStyles.numberField, true);
                if (EditorGUI.EndChangeCheck())
                {
                    m_Property.constantMax.floatValue = newConstantMax;
                }
                EditorGUI.EndProperty();
                break;
            }
        }
 public static Texture2D GetPreview(int previewWidth, int previewHeight, SerializedProperty property, SerializedProperty property2, Color color, Rect curveRanges)
 {
     return(AnimationCurvePreviewCache.GetPreview(previewWidth, previewHeight, property, property2, color, Color.clear, Color.clear));
 }
 public static Texture2D GetCurvePreview(int previewWidth, int previewHeight, bool useCurveRanges, Rect curveRanges, AnimationCurve curve, Color color)
 {
     return(AnimationCurvePreviewCache.INTERNAL_CALL_GetCurvePreview(previewWidth, previewHeight, useCurveRanges, ref curveRanges, curve, ref color));
 }
Exemplo n.º 11
0
 public static Texture2D GetPreview(int previewWidth, int previewHeight, AnimationCurve curve, AnimationCurve curve2, Color color, Rect curveRanges)
 {
     return(AnimationCurvePreviewCache.GetCurvePreviewRegion(previewWidth, previewHeight, true, curveRanges, curve, curve2, color));
 }
Exemplo n.º 12
0
 private static Texture2D GetCurvePreviewRegion(int previewWidth, int previewHeight, bool useCurveRanges, Rect curveRanges, AnimationCurve curve, AnimationCurve curve2, Color color)
 {
     return(AnimationCurvePreviewCache.GetCurvePreviewRegion_Injected(previewWidth, previewHeight, useCurveRanges, ref curveRanges, curve, curve2, ref color));
 }
Exemplo n.º 13
0
 private static Texture2D GetCurvePreviewFilled(int previewWidth, int previewHeight, bool useCurveRanges, Rect curveRanges, AnimationCurve curve, Color color, Color topFillColor, Color bottomFillColor)
 {
     return(AnimationCurvePreviewCache.GetCurvePreviewFilled_Injected(previewWidth, previewHeight, useCurveRanges, ref curveRanges, curve, ref color, ref topFillColor, ref bottomFillColor));
 }
Exemplo n.º 14
0
 private static Texture2D GetPropertyPreviewRegion(int previewWidth, int previewHeight, bool useCurveRanges, Rect curveRanges, SerializedProperty property, SerializedProperty property2, Color color)
 {
     return(AnimationCurvePreviewCache.GetPropertyPreviewRegion_Injected(previewWidth, previewHeight, useCurveRanges, ref curveRanges, property, property2, ref color));
 }
Exemplo n.º 15
0
 public static Texture2D GenerateCurvePreview(int previewWidth, int previewHeight, Rect curveRanges, AnimationCurve curve, Color color, Texture2D existingTexture)
 {
     return(AnimationCurvePreviewCache.GenerateCurvePreview_Injected(previewWidth, previewHeight, ref curveRanges, curve, ref color, existingTexture));
 }
 public static Texture2D GetPreview(int previewWidth, int previewHeight, AnimationCurve curve, Color color)
 {
     return(AnimationCurvePreviewCache.GetPreview(previewWidth, previewHeight, curve, color, Color.clear, Color.clear, default(Rect)));
 }
 public static Texture2D GetPropertyPreviewRegionFilled(int previewWidth, int previewHeight, bool useCurveRanges, Rect curveRanges, SerializedProperty property, SerializedProperty property2, Color color, Color topFillColor, Color bottomFillColor)
 {
     return(AnimationCurvePreviewCache.INTERNAL_CALL_GetPropertyPreviewRegionFilled(previewWidth, previewHeight, useCurveRanges, ref curveRanges, property, property2, ref color, ref topFillColor, ref bottomFillColor));
 }
Exemplo n.º 18
0
 public static Texture2D GetPreview(int previewWidth, int previewHeight, AnimationCurve curve, AnimationCurve curve2, Color color)
 {
     return(AnimationCurvePreviewCache.GetCurvePreviewRegion(previewWidth, previewHeight, false, default(Rect), curve, curve2, color));
 }
 public static Texture2D GetCurvePreviewRegionFilled(int previewWidth, int previewHeight, bool useCurveRanges, Rect curveRanges, AnimationCurve curve, AnimationCurve curve2, Color color, Color topFillColor, Color bottomFillColor)
 {
     return(AnimationCurvePreviewCache.INTERNAL_CALL_GetCurvePreviewRegionFilled(previewWidth, previewHeight, useCurveRanges, ref curveRanges, curve, curve2, ref color, ref topFillColor, ref bottomFillColor));
 }
 public static Texture2D GetPropertyPreview(int previewWidth, int previewHeight, bool useCurveRanges, Rect curveRanges, SerializedProperty property, Color color)
 {
     return(AnimationCurvePreviewCache.INTERNAL_CALL_GetPropertyPreview(previewWidth, previewHeight, useCurveRanges, ref curveRanges, property, ref color));
 }
 public static Texture2D GetPreview(int previewWidth, int previewHeight, SerializedProperty property, Color color, Color topFillColor, Color bottomFillColor)
 {
     return(AnimationCurvePreviewCache.GetPropertyPreviewFilled(previewWidth, previewHeight, false, default(Rect), property, color, topFillColor, bottomFillColor));
 }
 public static Texture2D GetPreview(int previewWidth, int previewHeight, SerializedProperty property, Color color)
 {
     return(AnimationCurvePreviewCache.GetPreview(previewWidth, previewHeight, property, color, Color.clear, Color.clear, default(Rect)));
 }
        static void DoMinMaxCurvesField(Rect position, int id, SerializedProperty propertyMax, SerializedProperty propertyMin, SerializedProperty scalar, Color color, Color backgroundColor)
        {
            var evt = Event.current;

            if (MinMaxCurveEditorWindow.visible && Event.current.type != EventType.Layout && GUIUtility.keyboardControl == id)
            {
                if (s_CurveId != id)
                {
                    s_CurveId = id;
                    if (MinMaxCurveEditorWindow.visible)
                    {
                        MinMaxCurveEditorWindow.SetCurves(propertyMax, propertyMin, scalar, color);
                        MinMaxCurveEditorWindow.ShowPopup(GUIView.current);
                    }
                }
                else
                {
                    if (MinMaxCurveEditorWindow.visible && Event.current.type == EventType.Repaint)
                    {
                        MinMaxCurveEditorWindow.SetCurves(propertyMax, propertyMin, scalar, color);
                        MinMaxCurveEditorWindow.instance.Repaint();
                    }
                }
            }

            switch (evt.GetTypeForControl(id))
            {
            case EventType.MouseDown:
                if (position.Contains(evt.mousePosition))
                {
                    s_CurveId = id;
                    GUIUtility.keyboardControl = id;
                    MinMaxCurveEditorWindow.SetCurves(propertyMax, propertyMin, scalar, color);
                    MinMaxCurveEditorWindow.ShowPopup(GUIView.current);
                    evt.Use();
                    GUIUtility.ExitGUI();
                }
                break;

            case EventType.Repaint:
                if (propertyMin != null)
                {
                    EditorGUIUtility.DrawRegionSwatch(position, propertyMax, propertyMin, color, backgroundColor);
                }
                else
                {
                    EditorGUIUtility.DrawCurveSwatch(position, null, propertyMax, color, backgroundColor);
                }
                EditorStyles.colorPickerBox.Draw(position, GUIContent.none, id, false);
                break;

            case EventType.ExecuteCommand:

                if (s_CurveId == id && evt.commandName == "CurveChanged")
                {
                    GUI.changed = true;
                    AnimationCurvePreviewCache.ClearCache();
                    HandleUtility.Repaint();
                    if (propertyMax != null && MinMaxCurveEditorWindow.instance.maxCurve != null)
                    {
                        propertyMax.animationCurveValue = MinMaxCurveEditorWindow.instance.maxCurve;
                    }
                    if (propertyMin != null)
                    {
                        propertyMin.animationCurveValue = MinMaxCurveEditorWindow.instance.minCurve;
                    }
                }
                break;

            case EventType.KeyDown:
                if (evt.MainActionKeyForControl(id))
                {
                    s_CurveId = id;
                    MinMaxCurveEditorWindow.SetCurves(propertyMax, propertyMin, scalar, color);
                    MinMaxCurveEditorWindow.ShowPopup(GUIView.current);
                    evt.Use();
                    GUIUtility.ExitGUI();
                }
                break;
            }
        }
Exemplo n.º 24
0
 public static Texture2D GetPreview(int previewWidth, int previewHeight, SerializedProperty property, Color color)
 {
     return(AnimationCurvePreviewCache.GetPropertyPreview(previewWidth, previewHeight, false, new Rect(), property, color));
 }