Exemplo n.º 1
0
 private void Defaults(TRSType trs)
 {
     if (trs == TRSType.Quaternion || trs == TRSType.Euler)
     {
         xcrusher = new FloatCrusher(BitPresets.Bits10, -90f, 90f, Axis.X, TRSType.Euler, true);
         ycrusher = new FloatCrusher(BitPresets.Bits12, -180f, 180f, Axis.Y, TRSType.Euler, true);
         zcrusher = new FloatCrusher(BitPresets.Bits10, -180f, 180f, Axis.Z, TRSType.Euler, true);
         //ucrusher = new FloatCrusher(Axis.Uniform, TRSType.Scale, true);
         qcrusher = new QuatCrusher(true, false);
     }
     else if (trs == TRSType.Scale)
     {
         xcrusher = new FloatCrusher(BitPresets.Bits12, 0f, 2f, Axis.X, TRSType.Scale, true);
         ycrusher = new FloatCrusher(BitPresets.Bits10, 0f, 2f, Axis.Y, TRSType.Scale, true);
         zcrusher = new FloatCrusher(BitPresets.Bits10, 0f, 2f, Axis.Z, TRSType.Scale, true);
         ucrusher = new FloatCrusher(BitPresets.Bits10, 0f, 2f, Axis.Uniform, TRSType.Scale, true);
     }
     else
     {
         xcrusher = new FloatCrusher(BitPresets.Bits12, -20f, 20f, Axis.X, trs, true);
         ycrusher = new FloatCrusher(BitPresets.Bits10, -5f, 5f, Axis.Y, trs, true);
         zcrusher = new FloatCrusher(BitPresets.Bits10, -5f, 5f, Axis.Z, trs, true);
     }
 }
 public CompressedQuat(QuatCrusher crusher, byte cvalue) : this()
 {
     this.crusher = crusher;
     this.cvalue  = cvalue;
 }
Exemplo n.º 3
0
        public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(r, label, property);

            base.OnGUI(r, property, label);

            property.serializedObject.Update();

            target = (QuatCrusher)DrawerUtils.GetParent(property.FindPropertyRelative("bits"));
            MonoBehaviour component = (MonoBehaviour)property.serializedObject.targetObject;

            if (target.transform == null)
            {
                target.transform = component.transform;
            }

            line = r.yMin;

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

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

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

            CompressLevel clvl = (CompressLevel)EditorGUI.EnumPopup(new Rect(paddedleft, line, labelwidth - PADDING, LINEHEIGHT), GUIContent.none, target.CompressLevel);

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

                else
                {
                    target.CompressLevel = clvl;
                }
            }

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


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

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

            if (QC_ISPRO && bitssp.intValue != target.Bits)
            {
                target.CompressLevel = CompressLevel.SetBits;
            }



            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();

            EditorGUI.EndProperty();
        }
Exemplo n.º 4
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);
            int newbits = EditorGUI.IntSlider(new Rect(fieldleft, line, fieldwidth, LINEHEIGHT), GUIContent.none, target.Bits, 16, 64);

            //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();
        }