Esempio n. 1
0
        private void DrawCompressionMethod()
        {
            BitsDeterminedBy btb = (BitsDeterminedBy)
                                   EditorGUI.EnumPopup(new Rect(ir.xMin + PADDING, line, labelwidth - 8, LINEHEIGHT), GUIContent.none, fc.BitsDeterminedBy);

            // IF we switched to pro - the btb value is actually the bits value, force a change to SetBits
            if (FC_ISPRO && btb >= 0)
            {
                fc.Bits = (int)btb;
            }

            else if (!FC_ISPRO && btb == BitsDeterminedBy.SetBits)            //.CustomBits)
            {
                // In case we went from pro to free... quietly set this back to non-custom.
                if (fc.BitsDeterminedBy != BitsDeterminedBy.SetBits)
                {
                    ProFeatureDialog("");
                }
                else
                {
                    fc.Bits = fc.Bits;
                }
            }
            else if (fc.BitsDeterminedBy != btb)
            {
                haschanged = true;
                Undo.RecordObject(p.serializedObject.targetObject, "Changed Crusher Bits Determined By");
                fc.BitsDeterminedBy = btb;
                p.serializedObject.Update();
            }

            float fieldleft  = paddedleft + labelwidth;
            float fieldwidth = paddedwidth - labelwidth;

            //const float labelW = 48f;
            const float inputW     = 50f;
            float       input2Left = paddedright - inputW;

            switch (fc.BitsDeterminedBy)
            {
            case BitsDeterminedBy.HalfFloat:
                break;

            case BitsDeterminedBy.Uncompressed:
                break;

            case BitsDeterminedBy.Disabled:
                break;

            case BitsDeterminedBy.Resolution:

                EditorGUI.LabelField(new Rect(rightinputsleft - 128, line, 128, LINEHEIGHT), new GUIContent(holdindent < 2 ? "Min resolution: 1/" : "Min res 1/"), miniLabelRight);

                uint res = (uint)EditorGUI.DelayedIntField(new Rect(input2Left, line - 1, inputW, LINEHEIGHT), GUIContent.none, (int)fc.Resolution);

                if (fc.Resolution != res)
                {
                    haschanged = true;
                    Undo.RecordObject(p.serializedObject.targetObject, "Changed Resolution value");
                    fc.Resolution = res;
                }

                break;

            case BitsDeterminedBy.Precision:

                EditorGUI.LabelField(new Rect(rightinputsleft - 128, line, 128, LINEHEIGHT), new GUIContent((holdindent < 2) ? "Min precision: " : "Min prec: "), miniLabelRight);
                float precision = EditorGUI.DelayedFloatField(new Rect(input2Left, line - 1, inputW, LINEHEIGHT), GUIContent.none, fc.Precision);

                if (fc.Precision != precision)
                {
                    haschanged = true;
                    Undo.RecordObject(p.serializedObject.targetObject, "Changed Precision value");
                    fc.Precision = (float)Math.Round(precision * 100000) / 100000;
                }

                break;

            default:

                if (FC_ISPRO && fc.BitsDeterminedBy == (BitsDeterminedBy.SetBits))
                {
                    EditorGUI.indentLevel = holdindent;
#if UNITY_2019_3_OR_NEWER
                    int bits = EditorGUI.IntSlider(new Rect(fieldleft, line, fieldwidth, LINEHEIGHT + 2), GUIContent.none, fc.Bits, 0, 32);
#else
                    int bits = EditorGUI.IntSlider(new Rect(fieldleft, line, fieldwidth, LINEHEIGHT), GUIContent.none, fc.Bits, 0, 32);
#endif
                    EditorGUI.indentLevel = 0;

                    if (fc.Bits != bits)
                    {
                        haschanged = true;
                        Undo.RecordObject(p.serializedObject.targetObject, "Changed Bits value");
                        fc.Bits = bits;
                    }
                    break;
                }

                float sliderleft  = ir.xMin + PADDING + labelwidth;                        // ir.xMin + PADDING + labelwidth;
                float sliderwidth = ir.width - PADDING - labelwidth - PADDING;             // - sliderleft - PADDING;

                GUI.enabled = false;
#if UNITY_2019_3_OR_NEWER
                EditorGUI.IntSlider(new Rect(sliderleft, line, sliderwidth, LINEHEIGHT + 2), GUIContent.none, (int)fc.BitsDeterminedBy, 0, 32);
#else
                EditorGUI.IntSlider(new Rect(sliderleft, line, sliderwidth, LINEHEIGHT), GUIContent.none, (int)fc.BitsDeterminedBy, 0, 32);
#endif
                //EditorGUI.IntSlider(new Rect(fieldleft, line, fieldwidth, LINEHEIGHT), GUIContent.none, (int)fc.BitsDeterminedBy, 0, 32);
                GUI.enabled = true;

                break;
            }

            line += COMPMTHD_HGHT;
        }
Esempio n. 2
0
        private void DrawResolution()
        {
            BitsDeterminedBy btb = (BitsDeterminedBy)
                                   EditorGUI.EnumPopup(new Rect(paddedleft, line, labelwidth - 8, LINEHEIGHT), GUIContent.none, fc.BitsDeterminedBy);

            // IF we switched to pro - the btb value is actually the bits value, force a change to SetBits
            if (FC_ISPRO && btb >= 0)
            {
                fc.Bits = (int)btb;
            }

            else if (!FC_ISPRO && btb == BitsDeterminedBy.SetBits)            //.CustomBits)
            {
                // In case we went from pro to free... quietly set this back to non-custom.
                if (fc.BitsDeterminedBy == BitsDeterminedBy.SetBits)
                {
                    fc.Bits = ((int)BitsDeterminedBy.SetBits > -1) ? (int)BitsDeterminedBy.SetBits : fc.Bits;
                }
                else
                {
                    ProFeatureDialog("");
                }
            }
            else if (fc.BitsDeterminedBy != btb)
            {
                fc.BitsDeterminedBy = btb;
            }

            float fieldleft  = paddedleft + labelwidth;
            float fieldwidth = paddedwidth - labelwidth;

            switch (fc.BitsDeterminedBy)
            {
            case BitsDeterminedBy.HalfFloat:
                break;

            case BitsDeterminedBy.Resolution:

                EditorGUI.LabelField(new Rect(rightinputsleft - 128, line, 128, LINEHEIGHT), new GUIContent("Min resolution: 1/"), miniLabelRight);
                uint res = (uint)EditorGUI.IntField(new Rect(rightinputsleft, line, stdfieldwidth, LINEHEIGHT), GUIContent.none, (int)fc.Resolution);

                //if (fc.Resolution != res)
                fc.Resolution = res;

                break;

            case BitsDeterminedBy.Precision:

                EditorGUI.LabelField(new Rect(rightinputsleft - 128, line, 128, LINEHEIGHT), new GUIContent("Min precicion: "), miniLabelRight);
                float precision = EditorGUI.FloatField(new Rect(rightinputsleft, line, stdfieldwidth, LINEHEIGHT), GUIContent.none, fc.Precision);

                //if (fc.Precision != precision)
                fc.Precision = (float)Math.Round(precision * 100000) / 100000;

                break;

            default:

                if (FC_ISPRO && fc.BitsDeterminedBy == (BitsDeterminedBy.SetBits))
                {
                    int bits = EditorGUI.IntSlider(new Rect(fieldleft, line, fieldwidth, LINEHEIGHT), GUIContent.none, fc.Bits, 0, 32);

                    if (fc.Bits != bits)
                    {
                        fc.Bits = bits;
                    }
                    break;
                }

                GUI.enabled = false;
                EditorGUI.IntSlider(new Rect(fieldleft, line, fieldwidth, LINEHEIGHT), GUIContent.none, (int)fc.BitsDeterminedBy, 0, 32);
                GUI.enabled = true;

                break;
            }
        }