예제 #1
0
        protected override void OnSceneGUI()
        {
            // Bounds
            if (CurvyGlobalManager.Gizmos.HasFlag(CurvySplineGizmos.Bounds))
            {
                DTHandles.PushHandlesColor(new Color(0.3f, 0, 0));
                DTHandles.WireCubeCap(Target.Bounds.center, Target.Bounds.size);
                DTHandles.PopHandlesColor();
            }
            Handles.BeginGUI();

            mUserValuesLabel = new GUIStyle(EditorStyles.boldLabel);
            mUserValuesLabel.normal.textColor = Color.green;


            if (CurvyGlobalManager.Gizmos.HasFlag(CurvySplineGizmos.Labels))
            {
                GUIStyle stLabel = new GUIStyle(EditorStyles.boldLabel);
                stLabel.normal.textColor = Color.white;
                Handles.Label(Target.transform.position - new Vector3(-0.5f, 0.2f, 0), Target.name, stLabel);
                stLabel.normal.textColor = Color.red;
                foreach (CurvySplineSegment cp in Target.ControlPoints)
                {
                    Handles.Label(cp.transform.position + new Vector3(-0.5f, HandleUtility.GetHandleSize(cp.transform.position) * 0.35f, 0), cp.name, stLabel);
                }
            }

            Handles.EndGUI();
            // Snap Transform
            if (Target && DT._UseSnapValuePrecision)
            {
                Target.transform.localPosition    = DTMath.SnapPrecision(Target.transform.localPosition, 3);
                Target.transform.localEulerAngles = DTMath.SnapPrecision(Target.transform.localEulerAngles, 3);
            }
        }
예제 #2
0
        void validateTo()
        {
            ppTo.floatValue = DTMath.SnapPrecision(ppTo.floatValue, Attribute.Precision);
            switch (mOptions.ClampTo)
            {
            case DTValueClamping.Min:
                ppTo.floatValue = Mathf.Max(mOptions.ToMin, ppTo.floatValue);
                break;

            case DTValueClamping.Max:
                ppTo.floatValue = Mathf.Min(mOptions.ToMax, ppTo.floatValue);
                break;

            case DTValueClamping.Range:
                ppTo.floatValue = Mathf.Clamp(ppTo.floatValue, mOptions.ToMin, mOptions.ToMax);
                if (minmax)
                {
                    ppTo.floatValue = Mathf.Max(ppTo.floatValue, ppFrom.floatValue);
                }
                break;
            }
        }
예제 #3
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            base.OnGUI(position, property, label);

            // GUI
            EditorGUI.PropertyField(position, property, label);


            maxV = Attribute.MaxValue;

            if (!string.IsNullOrEmpty(Attribute.MaxFieldOrPropertyName))
            {
                maxV = GetMemberValue <float>(property, Attribute.MaxFieldOrPropertyName);
            }

            // Clamp and snap
            switch (property.propertyType)
            {
            case SerializedPropertyType.Float:
                if (DT._UseSnapValuePrecision && Attribute.Precision > -1)
                {
                    property.floatValue = DTMath.SnapPrecision(property.floatValue, Attribute.Precision);
                }
                if (property.floatValue > maxV)
                {
                    property.floatValue = maxV;
                }

                break;

            case SerializedPropertyType.Integer:
                if (property.intValue > maxV)
                {
                    property.intValue = (int)maxV;
                }
                break;
            }
            label.tooltip = "";
        }
예제 #4
0
        public override void OnModuleSceneDebugGUI()
        {
            base.OnModuleSceneDebugGUI();
            CGVolume vol = Target.InData.GetData <CGVolume>();

            if (vol)
            {
                Handles.matrix = Target.Generator.transform.localToWorldMatrix;

                if (Target.ShowPathSamples)
                {
                    CGEditorUtility.SceneGUIPlot(vol.Position, 0.1f, Target.PathColor);
                    if (Target.ShowIndex)
                    {
                        var labels = Enumerable.Range(0, vol.Count).Select(i => i.ToString()).ToArray <string>();
                        CGEditorUtility.SceneGUILabels(vol.Position, labels, Color.black, Vector2.zero);
                    }
                }
                if (Target.ShowCrossSamples)
                {
                    int vtLo = Target.LimitCross.From * vol.CrossSize;
                    int vtHi = vtLo + vol.CrossSize;
                    if (!Target.LimitCross.SimpleValue)
                    {
                        vtLo = Target.LimitCross.Low * vol.CrossSize;
                        vtHi = (Target.LimitCross.High + 1) * vol.CrossSize;
                    }

                    vtLo = Mathf.Clamp(vtLo, 0, vol.VertexCount);
                    vtHi = Mathf.Clamp(vtHi, vtLo, vol.VertexCount);
                    var range = vol.Vertex.SubArray <Vector3>(vtLo, vtHi - vtLo);
                    CGEditorUtility.SceneGUIPlot(range, 0.1f, Color.white);

                    if (Target.ShowIndex)
                    {
                        var labels = Enumerable.Range(vtLo, vtHi).Select(i => i.ToString()).ToArray <string>();
                        CGEditorUtility.SceneGUILabels(range, labels, Color.black, Vector2.zero);
                    }

                    if (Target.ShowMap)
                    {
                        var labels = Enumerable.Range(vtLo, vtHi).Select(i => DTMath.SnapPrecision(vol.CrossMap[i], 3).ToString()).ToArray <string>();
                        CGEditorUtility.SceneGUILabels(range, labels, new Color(1, 0, 1), new Vector2(10, 20));
                    }

                    if (Target.ShowNormals)
                    {
                        DTHandles.PushHandlesColor(Target.NormalColor);

                        for (int i = vtLo; i < vtHi; i++)
                        {
                            Handles.DrawLine(vol.Vertex[i], vol.Vertex[i] + vol.VertexNormal[i] * 2);
                        }

                        DTHandles.PopHandlesColor();
                    }
                }
                if (Target.Interpolate)
                {
                    Vector3 pos;
                    Vector3 tan;
                    Vector3 up;
                    vol.InterpolateVolume(Target.InterpolatePathF, Target.InterpolateCrossF, out pos, out tan, out up);
                    Handles.ConeCap(0, pos, Quaternion.LookRotation(up, tan), 1f);
                }
                Handles.matrix = Matrix4x4.identity;
            }
        }
예제 #5
0
        /*! \endcond */
        #endregion

        #region ### Public Methods ###

        public override void Refresh()
        {
            base.Refresh();
            if (Length == 0)
            {
                Reset();
            }
            else
            {
                var req = new List <CGDataRequestParameter>();
                req.Add(new CGDataRequestRasterization(this.From, this.Length, CGUtility.CalculateSamplePointsCacheSize(Resolution, InPath.SourceSlot().OnRequestPathModule.PathLength *this.Length), AngleThreshold, (Optimize) ? CGDataRequestRasterization.ModeEnum.Optimized : CGDataRequestRasterization.ModeEnum.Even));
                var path = InPath.GetData <CGPath>(req.ToArray());
                req.Clear();
                req.Add(new CGDataRequestRasterization(this.CrossFrom, this.CrossLength, CGUtility.CalculateSamplePointsCacheSize(CrossResolution, InCross.SourceSlot().OnRequestPathModule.PathLength *this.CrossLength), CrossAngleThreshold, (CrossOptimize) ? CGDataRequestRasterization.ModeEnum.Optimized : CGDataRequestRasterization.ModeEnum.Even));

                if (CrossIncludeControlPoints || CrossHardEdges || CrossMaterials)
                {
                    req.Add(new CGDataRequestMetaCGOptions(CrossHardEdges, CrossMaterials, CrossIncludeControlPoints, CrossExtendedUV));
                }

                var cross = InCross.GetData <CGShape>(req.ToArray());

                if (!path || !cross || path.Count == 0 || cross.Count == 0)
                {
                    OutVolume.ClearData();
                    OutVolumeHollow.ClearData();
                    return;
                }


                var vol       = CGVolume.Get(OutVolume.GetData <CGVolume>(), path, cross);
                var volHollow = (OutVolumeHollow.IsLinked) ? CGVolume.Get(OutVolumeHollow.GetData <CGVolume>(), path, cross) : null;

                PathSamples   = path.Count;
                CrossSamples  = cross.Count;
                CrossGroups   = cross.MaterialGroups.Count;
                CrossPosition = vol.Position[0];
                CrossRotation = Quaternion.LookRotation(vol.Direction[0], vol.Normal[0]);



                Vector3 baseScale = (ScaleUniform) ? new Vector3(ScaleX, ScaleX, 1) : new Vector3(ScaleX, ScaleY, 1);
                Vector3 scl       = baseScale;
                int     vtIdx     = 0;

                float[] scaleFArray = (ScaleReference == CGReferenceMode.Source) ? path.SourceF : path.F;

                Matrix4x4 mat;
                Matrix4x4 matHollow;

                Quaternion R;
                int        crossNormalMul  = (CrossReverseNormals) ? -1 : 1;
                int        hollowNormalMul = (HollowReverseNormals) ? -1 : 1;
                for (int sample = 0; sample < path.Count; sample++)
                {
                    R = Quaternion.LookRotation(path.Direction[sample], path.Normal[sample]);

                    getScaleInternal(scaleFArray[sample], baseScale, ref scl);
                    mat = Matrix4x4.TRS(path.Position[sample], R, scl);

                    if (volHollow == null)
                    {
                        for (int c = 0; c < cross.Count; c++)
                        {
                            vol.Vertex[vtIdx]         = mat.MultiplyPoint(cross.Position[c]);
                            vol.VertexNormal[vtIdx++] = R * cross.Normal[c] * crossNormalMul;
                        }
                    }
                    else
                    {
                        matHollow = Matrix4x4.TRS(path.Position[sample], R, scl * (1 - HollowInset));
                        for (int c = 0; c < cross.Count; c++)
                        {
                            vol.Vertex[vtIdx]             = mat.MultiplyPoint(cross.Position[c]);
                            vol.VertexNormal[vtIdx]       = R * cross.Normal[c];
                            volHollow.Vertex[vtIdx]       = matHollow.MultiplyPoint(cross.Position[c]);
                            volHollow.VertexNormal[vtIdx] = vol.VertexNormal[vtIdx++] * hollowNormalMul;
                        }
                    }
                }



                switch (CrossShiftMode)
                {
                case CrossShiftModeEnum.ByOrientation:
                    // shift CrossF to match Path Orientation
                    Vector2 hit;
                    float   frag;
                    for (int i = 0; i < cross.Count - 1; i++)
                    {
                        if (DTMath.RayLineSegmentIntersection(vol.Position[0], vol.VertexNormal[0], vol.Vertex[i], vol.Vertex[i + 1], out hit, out frag))
                        {
                            vol.CrossFShift = DTMath.SnapPrecision(vol.CrossF[i] + (vol.CrossF[i + 1] - vol.CrossF[i]) * frag, 2);
                            break;
                        }
                    }
                    if (vol.CrossClosed && DTMath.RayLineSegmentIntersection(vol.Position[0], vol.VertexNormal[0], vol.Vertex[cross.Count - 1], vol.Vertex[0], out hit, out frag))
                    {
                        vol.CrossFShift = DTMath.SnapPrecision(vol.CrossF[cross.Count - 1] + (vol.CrossF[0] - vol.CrossF[cross.Count - 1]) * frag, 2);
                    }
                    break;

                case CrossShiftModeEnum.Custom:
                    vol.CrossFShift = CrossShiftValue;
                    break;

                default:
                    vol.CrossFShift = 0;
                    break;
                }

                if (volHollow != null)
                {
                    volHollow.CrossFShift = vol.CrossFShift;
                }

                OutVolume.SetData(vol);
                OutVolumeHollow.SetData(volHollow);
            }
        }
        protected override void OnSceneGUI()
        {
            // Bounds
            if (CurvyGlobalManager.Gizmos.HasFlag(CurvySplineGizmos.Bounds))
            {
                DTHandles.PushHandlesColor(Color.gray);
                DTHandles.WireCubeCap(Target.Bounds.center, Target.Bounds.size);
                DTHandles.PopHandlesColor();
            }
            checkHotkeys();
            if (Target.Spline.RestrictTo2D && Tools.current == Tool.Move && !SceneView.currentDrawingSceneView.in2DMode)
            {
                Tools.hidden = true;
                Vector3 handlePos = (Tools.handlePosition != Target.transform.position) ? DTSelection.GetPosition() : Tools.handlePosition;
                Vector3 delta;
                EditorGUI.BeginChangeCheck();


                if (CurvyProject.Instance.UseTiny2DHandles)
                {
                    delta = DTHandles.TinyHandle2D(GUIUtility.GetControlID(GetHashCode(), FocusType.Passive), handlePos, Target.Spline.transform.rotation, 1) - handlePos;
                }
                else
                {
                    delta = DTHandles.PositionHandle2D(GUIUtility.GetControlID(GetHashCode(), FocusType.Passive), handlePos, Target.Spline.transform.rotation, 1) - handlePos;
                }

                if (EditorGUI.EndChangeCheck())
                {
                    foreach (var t in Selection.transforms)
                    {
                        Undo.ClearUndo(t);
                        Undo.RecordObject(t, "Move");
                        t.position += delta;
                    }
                }
            }
            else
            {
                Tools.hidden = false;
            }


            // Bezier-Handles
            if (Target.Spline.Interpolation == CurvyInterpolation.Bezier && !Target.AutoHandles)
            {
                #region --- Bezier Rotation Handling ---
                if (Tools.current == Tool.Rotate)
                {
                    Event e = Event.current;
                    if (e.shift && DTHandles.MouseOverSceneView)
                    {
                        Tools.hidden = true;
                        DTToolbarItem._StatusBar.Set("BezierRotate");
                        // This looks good, but then diff down below isn't working like intended:
                        //mBezierRot = Quaternion.LookRotation(Vector3.Cross(Target.HandleIn, Target.GetOrientationUpFast(0)), Target.GetOrientationUpFast(0));
                        Quaternion newRot = Handles.RotationHandle(mBezierRot, Target.transform.position);
                        if (newRot != mBezierRot)
                        {
                            Quaternion diff = Quaternion.Inverse(mBezierRot) * newRot;
                            mBezierRot = newRot;
                            var mode = CurvyProject.Instance.BezierMode | CurvyBezierModeEnum.Direction;
                            Undo.RecordObject(Target, "Rotate Handles");
                            Target.SetBezierHandleIn(diff * Target.HandleIn, Space.Self, mode);
                            Target.SetDirty();
                            EditorUtility.SetDirty(Target);
                        }
                    }
                    else
                    {
                        DTToolbarItem._StatusBar.Set("Hold <b>[Shift]</b> to rotate Handles", "BezierRotate");
                        Tools.hidden = false;
                    }
                }
                else
                {
                    DTToolbarItem._StatusBar.Set("BezierRotate");
                }
                #endregion

                #region --- Bezier Movement Handling ---
                //Belongs to Constraint Length:
                //Vector3 handleOut = Target.HandleOutPosition;
                //Vector3 handleIn = Target.HandleInPosition;

                EditorGUI.BeginChangeCheck();
                Vector3 pOut;
                Vector3 pIn;
                bool    chgOut = false;
                bool    chgIn  = false;
                if (Target.Spline.RestrictTo2D)
                {
                    Quaternion r = (Tools.pivotRotation == PivotRotation.Global) ? Target.Spline.transform.localRotation : Target.Spline.transform.rotation;
                    Handles.color = Color.yellow;
                    pIn           = Target.HandleInPosition;
                    pIn           = DTHandles.TinyHandle2D(GUIUtility.GetControlID(FocusType.Passive), pIn, r, CurvyGlobalManager.GizmoControlPointSize * 0.7f, Handles.CubeCap);
                    if (!CurvyProject.Instance.UseTiny2DHandles)
                    {
                        pIn = DTHandles.PositionHandle2D(GUIUtility.GetControlID(FocusType.Passive), pIn, r, 1);
                    }
                    chgIn         = Target.HandleInPosition != pIn;
                    Handles.color = Color.green;
                    pOut          = Target.HandleOutPosition;
                    pOut          = DTHandles.TinyHandle2D(GUIUtility.GetControlID(FocusType.Passive), pOut, r, CurvyGlobalManager.GizmoControlPointSize * 0.7f, Handles.CubeCap);
                    if (!CurvyProject.Instance.UseTiny2DHandles)
                    {
                        pOut = DTHandles.PositionHandle2D(GUIUtility.GetControlID(FocusType.Passive), pOut, r, 1);
                    }

                    chgOut = Target.HandleOutPosition != pOut;
                }
                else
                {
                    pIn   = Handles.PositionHandle(Target.HandleInPosition, Tools.handleRotation);
                    chgIn = Target.HandleInPosition != pIn;
                    DTHandles.PushHandlesColor(Color.yellow);
                    Handles.CubeCap(0, pIn, Quaternion.identity, HandleUtility.GetHandleSize(pIn) * CurvyGlobalManager.GizmoControlPointSize * 0.7f);
                    DTHandles.PopHandlesColor();
                    pOut   = Handles.PositionHandle(Target.HandleOutPosition, Tools.handleRotation);
                    chgOut = Target.HandleOutPosition != pOut;
                    DTHandles.PushHandlesColor(Color.green);
                    Handles.CubeCap(0, pOut, Quaternion.identity, HandleUtility.GetHandleSize(pOut) * CurvyGlobalManager.GizmoControlPointSize * 0.7f);
                    DTHandles.PopHandlesColor();
                }

                Handles.color = Color.yellow;
                Handles.DrawLine(pIn, Target.transform.position);
                Handles.color = Color.green;
                Handles.DrawLine(pOut, Target.transform.position);


                if (chgOut || chgIn)
                {
                    Undo.RecordObject(Target, "Move Handle");
                    if (chgOut)
                    {
                        Target.SetBezierHandleOut(pOut, Space.World, CurvyProject.Instance.BezierMode);
                        Target.HandleOut = DTMath.SnapPrecision(Target.HandleOut, 3);
                    }
                    else
                    {
                        Target.SetBezierHandleIn(pIn, Space.World, CurvyProject.Instance.BezierMode);
                        Target.HandleIn = DTMath.SnapPrecision(Target.HandleIn, 3);
                    }
                }

                if (EditorGUI.EndChangeCheck())
                {
                    EditorUtility.SetDirty(Target);
                    Target.SetDirty();

                    /*
                     * var lcons = CurvyProject.Instance.FindItem<TBCPLengthConstraint>();
                     * if (lcons.On && Target.Spline.Length > lcons.MaxSplineLength)
                     * {
                     *  Target.HandleOutPosition = handleOut;
                     *  Target.HandleInPosition = handleIn;
                     *  Target.SetDirty();
                     * }
                     */
                }
                #endregion
            }
            if (mConnectionEditor)
            {
                mConnectionEditor.OnSceneGUI();
            }
            // Snap Transform
            if (Target && DT._UseSnapValuePrecision)
            {
                Target.transform.localPosition    = DTMath.SnapPrecision(Target.transform.localPosition, 3);
                Target.transform.localEulerAngles = DTMath.SnapPrecision(Target.transform.localEulerAngles, 3);
                //Target.TTransform.FromTransform(Target.transform);
            }
        }
예제 #7
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            base.OnGUI(position, property, label);

            lBound = Attribute.Min;
            uBound = Attribute.Max;
            // Get maxV serialized
            var path = property.Path();

            path[path.Length - 1] = Attribute.MaxValueField;
            var pMaxV = property.serializedObject.FindProperty(string.Join(".", path));

            if (!string.IsNullOrEmpty(Attribute.MinBoundFieldOrPropertyName))
            {
                lBound = GetMemberValue <float>(property, Attribute.MinBoundFieldOrPropertyName);
            }

            if (!string.IsNullOrEmpty(Attribute.MaxBoundFieldOrPropertyName))
            {
                uBound = GetMemberValue <float>(property, Attribute.MaxBoundFieldOrPropertyName);
            }

            if (lBound > uBound)
            {
                float temp = lBound;
                lBound = uBound;
                uBound = temp;
            }

            float minV = 0;
            float maxV = 0;

            // GUI
            EditorGUI.BeginChangeCheck();


            switch (property.propertyType)
            {
            case SerializedPropertyType.Float:
                minV = property.floatValue;
                maxV = pMaxV.floatValue;
                EditorGUI.MinMaxSlider(label, position, ref minV, ref maxV, lBound, uBound);
                break;

            case SerializedPropertyType.Integer:
                minV = property.intValue;
                maxV = pMaxV.intValue;
                EditorGUI.MinMaxSlider(label, position, ref minV, ref maxV, lBound, uBound);
                break;
            }

            if (EditorGUI.EndChangeCheck())
            {
                // Clamp
                switch (property.propertyType)
                {
                case SerializedPropertyType.Float:
                    if (DT._UseSnapValuePrecision && Attribute.Precision > -1)
                    {
                        property.floatValue = Mathf.Max(lBound, DTMath.SnapPrecision(minV, Attribute.Precision));
                    }
                    pMaxV.floatValue = Mathf.Min(uBound, DTMath.SnapPrecision(maxV, Attribute.Precision));
                    break;

                case SerializedPropertyType.Integer:
                    property.intValue = (int)minV;
                    pMaxV.intValue    = (int)maxV;
                    break;
                }
            }
            label.tooltip = "";
        }
예제 #8
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            base.OnGUI(position, property, label);


            minV = Attribute.MinValue;
            maxV = Attribute.MaxValue;

            if (!string.IsNullOrEmpty(Attribute.MinFieldOrPropertyName))
            {
                minV = GetMemberValue <float>(property, Attribute.MinFieldOrPropertyName);
            }

            if (!string.IsNullOrEmpty(Attribute.MaxFieldOrPropertyName))
            {
                maxV = GetMemberValue <float>(property, Attribute.MaxFieldOrPropertyName);
            }

            if (minV > maxV)
            {
                float temp = minV;
                minV = maxV;
                maxV = temp;
            }

            // GUI
            EditorGUI.BeginChangeCheck();
            if (Attribute.Slider)
            {
                switch (property.propertyType)
                {
                case SerializedPropertyType.Float:
                    EditorGUI.Slider(position, property, minV, maxV, label);
                    break;

                case SerializedPropertyType.Integer:
                    EditorGUI.IntSlider(position, property, (int)minV, (int)maxV, label);
                    break;
                }
            }
            else
            {
                EditorGUI.PropertyField(position, property, label);
            }

            if (EditorGUI.EndChangeCheck())
            {
                // Clamp
                switch (property.propertyType)
                {
                case SerializedPropertyType.Float:
                    if (DT._UseSnapValuePrecision && Attribute.Precision > -1)
                    {
                        property.floatValue = DTMath.SnapPrecision(property.floatValue, Attribute.Precision);
                    }
                    if (property.floatValue < minV || property.floatValue > maxV)
                    {
                        property.floatValue = Mathf.Clamp(property.floatValue, minV, maxV);
                    }
                    break;

                case SerializedPropertyType.Integer:
                    if (property.intValue < minV || property.intValue > maxV)
                    {
                        property.intValue = Mathf.Clamp(property.intValue, (int)minV, (int)maxV);
                    }
                    break;
                }
            }
            label.tooltip = "";
        }
예제 #9
0
        public static void DoGUI(Rect position, SerializedProperty property, DTPropertyAttribute attribute, GUIContent label, AttributeOptionsFlags flags, VectorExPropertyDrawer drawer = null)
        {
            if (property.propertyType != SerializedPropertyType.Vector2 && property.propertyType != SerializedPropertyType.Vector3 && property.propertyType != SerializedPropertyType.Quaternion)
            {
                Debug.LogError("DevTools: [VectorEx] only valid for Vector and Quaternion fields!");
            }
            else
            {
                Rect posb = position.WithoutLabel();
                posb.height = EditorGUIUtility.singleLineHeight;

                int buttons = 0;
                if (flags.HasFlag(AttributeOptionsFlags.Clipboard))
                {
                    buttons += 2;
                }
                if (flags.HasFlag(AttributeOptionsFlags.One))
                {
                    buttons++;
                }
                if (flags.HasFlag(AttributeOptionsFlags.Zero))
                {
                    buttons++;
                }
                if (flags.HasFlag(AttributeOptionsFlags.Negate))
                {
                    buttons++;
                }

                Rect r = position.WithoutLabel();
                r.width -= buttons * 20;

                if (flags.HasFlag(AttributeOptionsFlags.Compact) || EditorGUIUtility.wideMode)
                {
                    if (drawer != null)
                    {
                        drawer.PushCustomColors();
                    }
                    EditorGUI.PrefixLabel(position, label);

                    if (property.propertyType == SerializedPropertyType.Vector2)
                    {
                        EditorGUI.BeginChangeCheck();
                        Vector2 v = DTGUI.CompactVector2Field(r, property.vector2Value);
                        if (EditorGUI.EndChangeCheck())
                        {
                            property.vector2Value = DT._UseSnapValuePrecision ? DTMath.SnapPrecision(v, attribute.Precision) : v;
                        }
                    }
                    else if (property.propertyType == SerializedPropertyType.Vector3)
                    {
                        EditorGUI.BeginChangeCheck();
                        Vector3 v = DTGUI.CompactVector3Field(r, property.vector3Value);
                        if (EditorGUI.EndChangeCheck())
                        {
                            property.vector3Value = DT._UseSnapValuePrecision ? DTMath.SnapPrecision(v, attribute.Precision) : v;
                        }
                    }
                    else if (property.propertyType == SerializedPropertyType.Quaternion)
                    {
                        EditorGUI.BeginChangeCheck();
                        Vector3 v = DTGUI.CompactVector3Field(r, DT._UseSnapValuePrecision ? DTMath.SnapPrecision(property.quaternionValue.eulerAngles, attribute.Precision) : property.quaternionValue.eulerAngles);
                        if (EditorGUI.EndChangeCheck())
                        {
                            property.quaternionValue = Quaternion.Euler(v);
                        }
                    }
                    if (drawer != null)
                    {
                        drawer.PopCustomColors();
                    }
                }
                else
                {
                    EditorGUI.BeginChangeCheck();
                    if (drawer != null)
                    {
                        drawer.PushCustomColors();
                    }
                    EditorGUI.PropertyField(position, property, label);
                    if (drawer != null)
                    {
                        drawer.PopCustomColors();
                    }
                    if (EditorGUI.EndChangeCheck() && DT._UseSnapValuePrecision)
                    {
                        if (property.propertyType == SerializedPropertyType.Vector2)
                        {
                            property.vector2Value = DTMath.SnapPrecision(property.vector2Value, attribute.Precision);
                        }
                        else if (property.propertyType == SerializedPropertyType.Vector3)
                        {
                            property.vector3Value = DTMath.SnapPrecision(property.vector3Value, attribute.Precision);
                        }
                    }
                }

                // Buttons
                posb       = posb.ShiftXBy(r.width);
                posb.width = 19;
                if (flags.HasFlag(AttributeOptionsFlags.Clipboard))
                {
                    if (GUI.Button(posb, new GUIContent("C", "Copy"), EditorStyles.miniButton))
                    {
                        if (property.propertyType == SerializedPropertyType.Vector2)
                        {
                            DT.ClipboardCopy(property.vector2Value);
                        }
                        else if (property.propertyType == SerializedPropertyType.Vector3)
                        {
                            DT.ClipboardCopy(property.vector3Value);
                        }
                    }
                    posb.x += 20;
                    // Can Paste?
                    if (property.propertyType == SerializedPropertyType.Vector2)
                    {
                        GUI.enabled = DT.ClipboardCanPasteTo <Vector2>();
                    }
                    else if (property.propertyType == SerializedPropertyType.Vector3)
                    {
                        GUI.enabled = DT.ClipboardCanPasteTo <Vector3>();
                    }

                    if (GUI.Button(posb, new GUIContent("P", "Pastge"), EditorStyles.miniButton))
                    {
                        if (property.propertyType == SerializedPropertyType.Vector2)
                        {
                            property.vector2Value = DT.ClipboardPaste <Vector2>();
                        }
                        else if (property.propertyType == SerializedPropertyType.Vector3)
                        {
                            property.vector3Value = DT.ClipboardPaste <Vector3>();
                        }
                    }
                    GUI.enabled = true;
                    posb.x     += 20;
                }
                if (flags.HasFlag(AttributeOptionsFlags.Zero))
                {
                    if (GUI.Button(posb, new GUIContent("0", "Set to zero"), EditorStyles.miniButton))
                    {
                        if (property.propertyType == SerializedPropertyType.Vector2)
                        {
                            property.vector2Value = Vector2.zero;
                        }
                        else if (property.propertyType == SerializedPropertyType.Vector3)
                        {
                            property.vector3Value = Vector3.zero;
                        }
                    }
                    posb.x += 20;
                }
                if (flags.HasFlag(AttributeOptionsFlags.One))
                {
                    if (GUI.Button(posb, new GUIContent("1", "Set to one"), EditorStyles.miniButton))
                    {
                        if (property.propertyType == SerializedPropertyType.Vector2)
                        {
                            property.vector2Value = Vector2.one;
                        }
                        else if (property.propertyType == SerializedPropertyType.Vector3)
                        {
                            property.vector3Value = Vector3.one;
                        }
                    }
                    posb.x += 20;
                }
                if (flags.HasFlag(AttributeOptionsFlags.Negate))
                {
                    if (GUI.Button(posb, new GUIContent("~", "Negate"), EditorStyles.miniButton))
                    {
                        if (property.propertyType == SerializedPropertyType.Vector2)
                        {
                            property.vector2Value *= -1;
                        }
                        else if (property.propertyType == SerializedPropertyType.Vector3)
                        {
                            property.vector3Value *= -1;
                        }
                    }
                    posb.x += 20;
                }
            }
        }