Exemple #1
0
 private void PresetCurveButtons(Rect position, Rect curveEditorRect)
 {
     if (this.m_CurveEditor.animationCurves.Length != 0)
     {
         this.InitDoubleCurvePresets();
         if (this.m_DoubleCurvePresets != null)
         {
             DoubleCurvePresetLibrary currentLib = this.m_DoubleCurvePresets.GetPresetLibraryEditor().GetCurrentLib();
             int   a    = (!(currentLib != null)) ? 0 : currentLib.Count();
             int   num  = Mathf.Min(a, 9);
             float num2 = 30f;
             float num3 = 15f;
             float num4 = 10f;
             float num5 = (float)num * num2 + (float)(num - 1) * num4;
             float num6 = (position.width - num5) * 0.5f;
             float num7 = (position.height - num3) * 0.5f;
             float num8 = 3f;
             if (num6 > 0f)
             {
                 num8 = num6;
             }
             this.PresetDropDown(new Rect(num8 - 20f + position.x, num7 + position.y, 16f, 16f));
             GUI.BeginGroup(position);
             Color color;
             Color.white.a = color.a * 0.6f;
             for (int i = 0; i < num; i++)
             {
                 if (i > 0)
                 {
                     num8 += num4;
                 }
                 Rect rect = new Rect(num8, num7, num2, num3);
                 if (rect.xMax > position.width)
                 {
                     break;
                 }
                 ParticleSystemCurveEditor.s_Styles.presetTooltip.tooltip = currentLib.GetName(i);
                 if (GUI.Button(rect, ParticleSystemCurveEditor.s_Styles.presetTooltip, GUIStyle.none))
                 {
                     DoubleCurve doubleCurve = currentLib.GetPreset(i) as DoubleCurve;
                     if (doubleCurve != null)
                     {
                         this.SetTopMostCurve(doubleCurve);
                         this.m_CurveEditor.ClearSelection();
                     }
                 }
                 if (Event.current.type == EventType.Repaint)
                 {
                     currentLib.Draw(rect, i);
                 }
                 num8 += num2;
             }
             GUI.EndGroup();
         }
     }
 }
 private void PresetCurveButtons(Rect position, Rect curveEditorRect)
 {
     if (this.m_CurveEditor.animationCurves.Length != 0)
     {
         this.InitDoubleCurvePresets();
         if (this.m_DoubleCurvePresets != null)
         {
             DoubleCurvePresetLibrary currentLib = this.m_DoubleCurvePresets.GetPresetLibraryEditor().GetCurrentLib();
             int a = (currentLib == null) ? 0 : currentLib.Count();
             int num2 = Mathf.Min(a, 9);
             float width = 30f;
             float height = 15f;
             float num5 = 10f;
             float num6 = (num2 * width) + ((num2 - 1) * num5);
             float num7 = (position.width - num6) * 0.5f;
             float y = (position.height - height) * 0.5f;
             float x = 3f;
             if (num7 > 0f)
             {
                 x = num7;
             }
             this.PresetDropDown(new Rect((x - 20f) + position.x, y + position.y, 16f, 16f));
             GUI.BeginGroup(position);
             Color.white.a *= 0.6f;
             for (int i = 0; i < num2; i++)
             {
                 if (i > 0)
                 {
                     x += num5;
                 }
                 Rect rect = new Rect(x, y, width, height);
                 s_Styles.presetTooltip.tooltip = currentLib.GetName(i);
                 if (GUI.Button(rect, s_Styles.presetTooltip, GUIStyle.none))
                 {
                     DoubleCurve preset = currentLib.GetPreset(i) as DoubleCurve;
                     if (preset != null)
                     {
                         this.SetTopMostCurve(preset);
                         this.m_CurveEditor.ClearSelection();
                     }
                 }
                 if (Event.current.type == EventType.Repaint)
                 {
                     currentLib.Draw(rect, i);
                 }
                 x += width;
             }
             GUI.EndGroup();
         }
     }
 }
Exemple #3
0
    private void PresetCurveButtons(Rect position, Rect curveEditorRect)
    {
        if (this.m_CurveEditor.animationCurves.Length == 0)
        {
            return;
        }
        this.InitDoubleCurvePresets();
        if (this.m_DoubleCurvePresets == null)
        {
            return;
        }
        DoubleCurvePresetLibrary currentLib = this.m_DoubleCurvePresets.GetPresetLibraryEditor().GetCurrentLib();
        int   num1   = Mathf.Min(!((UnityEngine.Object)currentLib != (UnityEngine.Object)null) ? 0 : currentLib.Count(), 9);
        float width  = 30f;
        float height = 15f;
        float num2   = 10f;
        float num3   = (float)((double)num1 * (double)width + (double)(num1 - 1) * (double)num2);
        float num4   = (float)(((double)position.width - (double)num3) * 0.5);
        float y      = (float)(((double)position.height - (double)height) * 0.5);
        float x      = 3f;

        if ((double)num4 > 0.0)
        {
            x = num4;
        }
        this.PresetDropDown(new Rect(x - 20f + position.x, y + position.y, 16f, 16f));
        GUI.BeginGroup(position);
        Color.white.a *= 0.6f;
        for (int index = 0; index < num1; ++index)
        {
            if (index > 0)
            {
                x += num2;
            }
            Rect rect = new Rect(x, y, width, height);
            ParticleSystemCurveEditor.s_Styles.presetTooltip.tooltip = currentLib.GetName(index);
            if (GUI.Button(rect, ParticleSystemCurveEditor.s_Styles.presetTooltip, GUIStyle.none))
            {
                DoubleCurve preset = currentLib.GetPreset(index) as DoubleCurve;
                if (preset != null)
                {
                    this.SetTopMostCurve(preset);
                    this.m_CurveEditor.ClearSelection();
                }
            }
            if (Event.current.type == EventType.Repaint)
            {
                currentLib.Draw(rect, index);
            }
            x += width;
        }
        GUI.EndGroup();
    }
    void PresetCurveButtons(Rect position, Rect curveEditorRect)
    {
        if (m_CurveEditor.animationCurves.Length == 0)
        {
            return;
        }

        InitDoubleCurvePresets();
        if (m_DoubleCurvePresets == null)
        {
            return;
        }

        DoubleCurvePresetLibrary curveLibrary = m_DoubleCurvePresets.GetPresetLibraryEditor().GetCurrentLib();
        const int maxNumPresets  = 9;
        int       numPresets     = (curveLibrary != null) ? curveLibrary.Count() : 0;
        int       showNumPresets = Mathf.Min(numPresets, maxNumPresets);

        float swatchWidth          = 30;
        float swatchHeight         = 15;
        float spaceBetweenSwatches = 10;
        float presetButtonsWidth   = showNumPresets * swatchWidth + (showNumPresets - 1) * spaceBetweenSwatches;
        float flexWidth            = (position.width - presetButtonsWidth) * 0.5f;

        // Preset swatch area
        float curY = (position.height - swatchHeight) * 0.5f;
        float curX = 3.0f;

        if (flexWidth > 0)
        {
            curX = flexWidth;
        }

        PresetDropDown(new Rect(curX - 20 + position.x, curY + position.y, 16, 16));

        GUI.BeginGroup(position);

        Color curveColor = Color.white;

        curveColor.a *= 0.6f;
        for (int i = 0; i < showNumPresets; i++)
        {
            if (i > 0)
            {
                curX += spaceBetweenSwatches;
            }

            Rect swatchRect = new Rect(curX, curY, swatchWidth, swatchHeight);

            if (swatchRect.xMax > position.width)
            {
                break;
            }

            s_Styles.presetTooltip.tooltip = curveLibrary.GetName(i);
            if (GUI.Button(swatchRect, s_Styles.presetTooltip, GUIStyle.none))
            {
                DoubleCurve presetDoubleCurve = curveLibrary.GetPreset(i) as DoubleCurve;
                if (presetDoubleCurve != null)
                {
                    SetTopMostCurve(presetDoubleCurve);
                    m_CurveEditor.ClearSelection();
                }
            }
            if (Event.current.type == EventType.Repaint)
            {
                curveLibrary.Draw(swatchRect, i);
            }

            curX += swatchWidth;
        }
        GUI.EndGroup();
    }