Esempio n. 1
0
        protected override void UpdateEnabledState()
        {
            bool enabled = ChiselSnappingToggleUtility.IsSnappingModeEnabled(settingsFlag);

            if (this.enabledSelf != enabled)
            {
                this.SetEnabled(enabled);
            }
        }
Esempio n. 2
0
        public override void OnGUI()
        {
            var groupRect = EditorGUILayout.GetControlRect(false, 0, kMinWidthLayout);

            if (styles == null)
            {
                styles = new Styles();
            }
            EditorGUI.BeginChangeCheck();
            {
                // TODO: implement all snapping types
                // TODO: add units (EditorGUI.s_UnitString?)
                //ChiselEditorSettings.ShowGrid = GUILayout.Toggle(ChiselEditorSettings.ShowGrid, "Show Grid", EditorStyles.miniButton, kShowGridButtonWidthOption);

                var usedSnappingModes = ChiselSnappingToggleUtility.CurrentSnapSettings();

                EditorGUILayout.GetControlRect(false, 1);

                {
                    var lineRect = EditorGUILayout.GetControlRect(false, styles.smallToggleStyle.fixedHeight);
                    lineRect.xMin++;
                    lineRect.xMax--;
                    {
                        var buttonRect = lineRect;
                        buttonRect.width = kSmallButtonWidth + styles.smallToggleStyle.margin.horizontal;
                        Snapping.TranslateSnappingEnabled = SmallToggleButton(buttonRect, Snapping.TranslateSnappingEnabled, styles.translateIcons);
                        var floatRect = lineRect;
                        floatRect.x      = buttonRect.xMax + 1;
                        floatRect.width -= buttonRect.width + 1;
                        ChiselEditorSettings.UniformSnapSize = PlusMinusFloatField(floatRect, ChiselEditorSettings.UniformSnapSize, kDoubleGridSize, kHalfGridSize, SnappingKeyboard.DoubleGridSizeRet, SnappingKeyboard.HalfGridSizeRet);
                    }
                }

                {
                    var lineRect = EditorGUILayout.GetControlRect(false, styles.smallToggleStyle.fixedHeight);
                    lineRect.xMin++;
                    lineRect.xMax--;

                    var buttonRect1 = lineRect;
                    var buttonRect2 = lineRect;
                    var floatRect1  = lineRect;
                    var floatRect2  = lineRect;
                    buttonRect1.width = kSmallButtonWidth + styles.smallToggleStyle.margin.horizontal;
                    buttonRect2.width = kSmallButtonWidth + styles.smallToggleStyle.margin.horizontal;

                    var floatLeftover     = lineRect.width - (buttonRect1.width + buttonRect2.width) - 2;
                    var halfFloatLeftover = Mathf.CeilToInt(floatLeftover / 2);
                    floatRect1.width = halfFloatLeftover - 1;
                    floatRect2.width = (floatLeftover - floatRect1.width) - 2;

                    floatRect1.x  = buttonRect1.xMax + 1;
                    buttonRect2.x = floatRect1.xMax + 3;
                    floatRect2.x  = buttonRect2.xMax;

                    {
                        Snapping.RotateSnappingEnabled  = SmallToggleButton(buttonRect1, Snapping.RotateSnappingEnabled, styles.rotateIcons);
                        ChiselEditorSettings.RotateSnap = PlusMinusFloatField(floatRect1, ChiselEditorSettings.RotateSnap, kDoubleRotateSnap, kHalfRotateSnap, SnappingKeyboard.DoubleRotateSnapRet, SnappingKeyboard.HalfRotateSnapRet);
                    }
                    {
                        Snapping.ScaleSnappingEnabled  = SmallToggleButton(buttonRect2, Snapping.ScaleSnappingEnabled, styles.scaleIcons);
                        ChiselEditorSettings.ScaleSnap = PlusMinusFloatField(floatRect2, ChiselEditorSettings.ScaleSnap, kDoubleScaleSnap, kHalfScaleSnap, SnappingKeyboard.DoubleScaleSnapRet, SnappingKeyboard.HalfScaleSnapRet);
                    }
                }
            }
            if (EditorGUI.EndChangeCheck())
            {
                ChiselEditorSettings.Save();
            }
        }