public CompressedQuat(QuatCrusher crusher, byte cvalue) : this()
 {
     this.crusher = crusher;
     this.cvalue  = cvalue;
 }
Exemple #2
0
        public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(r, label, property);

            haschanged = false;

            base.OnGUI(r, property, label);

            holdindent = EditorGUI.indentLevel;

            property.serializedObject.ApplyModifiedProperties();
            property.serializedObject.Update();

            target = (QuatCrusher)DrawerUtils.GetParent(property.FindPropertyRelative("bits"));


            line = r.yMin;

            //float standalonesheight = target.isStandalone ? (SPACING + LINEHEIGHT) * 2 : 0;
            //float boxheight = SPACING + HEADR_HGHT + SPACING + LINEHEIGHT + standalonesheight + SPACING;

            SolidTextures.DrawTexture(ir, SolidTextures.gray2D);

            //SolidTextures.DrawTexture(new Rect(ir.xMin - 1, line - 1, r.width + 2, boxheight + 2), SolidTextures.lowcontrast2D);
            //SolidTextures.DrawTexture(new Rect(ir.xMin, line, r.width, boxheight), SolidTextures.gray2D);

            line += SPACING;
            DrawHeader(new Rect(r));
            line += HEADR_HGHT + SPACING + SPACING;

            EditorGUI.indentLevel = 0;
            CompressLevel clvl = (CompressLevel)EditorGUI.EnumPopup(new Rect(ir.xMin + PADDING, line, labelwidth - PADDING, LINEHEIGHT), GUIContent.none, target.CompressLevel);

            EditorGUI.indentLevel = holdindent;

            if (!QC_ISPRO)
            {
                // In case we went from pro to free... quietly set this back to non-custom.
                if (target.CompressLevel == CompressLevel.SetBits)
                {
                    if (target.Bits != (int)target.CompressLevel)
                    {
                        haschanged     = true;
                        target.Enabled = true;
                        target.Bits    = (int)target.CompressLevel;                      // CompressLevel =  CompressLevel.uint32Med;
                    }
                }

                else if (clvl == CompressLevel.SetBits)
                {
                    ProFeatureDialog("");
                    if (target.CompressLevel != (CompressLevel)target.Bits)
                    {
                        haschanged           = true;
                        target.CompressLevel = (CompressLevel)target.Bits;
                    }
                }

                else
                {
                    if (target.CompressLevel != clvl)
                    {
                        target.Enabled       = true;
                        haschanged           = true;
                        target.CompressLevel = clvl;
                    }
                }
            }

            else if (clvl != target.CompressLevel)
            {
                haschanged           = true;
                target.CompressLevel = clvl;
            }

            //var bitssp = property.FindPropertyRelative("bits");

            GUI.enabled = (QC_ISPRO);
#if UNITY_2019_3_OR_NEWER
            int newbits = EditorGUI.IntSlider(new Rect(fieldleft, line, fieldwidth, LINEHEIGHT + 2), GUIContent.none, target.Bits, 16, 64);
#else
            int newbits = EditorGUI.IntSlider(new Rect(fieldleft, line, fieldwidth, LINEHEIGHT), GUIContent.none, target.Bits, 16, 64);
#endif

            //bool bitschanged = EditorGUI.PropertyField(new Rect(fieldleft, line, fieldwidth, LINEHEIGHT), bitssp, GUIContent.none);
            GUI.enabled = true;

            if (QC_ISPRO && newbits != target.Bits)
            {
                //if (target.CompressLevel != CompressLevel.SetBits)
                //{
                haschanged  = true;
                target.Bits = newbits;
                //target.CompressLevel = CompressLevel.SetBits;
                //}
                property.serializedObject.Update();
            }

            if (target.isStandalone)
            {
                line += LINEHEIGHT + SPACING;
                EditorGUI.PropertyField(new Rect(paddedleft, line, paddedwidth, LINEHEIGHT), property.FindPropertyRelative("transform"));
                line += LINEHEIGHT + SPACING;
                EditorGUI.PropertyField(new Rect(paddedleft, line, paddedwidth, LINEHEIGHT), property.FindPropertyRelative("local"));
            }

            property.serializedObject.ApplyModifiedProperties();

            if (haschanged)
            {
                EditorUtility.SetDirty(property.serializedObject.targetObject);
                //AssetDatabase.SaveAssets();
            }

            EditorGUI.EndProperty();
        }