Exemplo n.º 1
0
        public static void DoDraw(Rect position, SerializedProperty property, GUIContent label)
        {
            using (var propScope = Disposables.PropertyScope(position, label, property)) {
                position.height = SingleLine;
                label           = propScope.content;
                var labelPos = position.Edit(RectEdit.SetWidth(EditorGUIUtility.labelWidth));
                FoCsGUI.Label(labelPos, label);

                using (var scope = Disposables.RectHorizontalScope(6, position.Edit(RectEdit.AddX(labelPos.width), RectEdit.SetWidth(position.width - labelPos.width)))) {
                    using (Disposables.IndentSet(0)) {
                        using (var innerScope = Disposables.RectHorizontalScope(3, scope.GetNext(2))) {
                            FoCsGUI.Label(innerScope.GetNext(), KEY_LABEL);
                            FoCsGUI.PropertyField(innerScope.GetNext(2), property.FindPropertyRelative(KEY), GUIContent.none);
                        }

                        using (var innerScope = Disposables.RectHorizontalScope(5, scope.GetNext(2))) {
                            FoCsGUI.Label(innerScope.GetNext(2), KEY_TYPE_LABEL);
                            FoCsGUI.PropertyField(innerScope.GetNext(3), property.FindPropertyRelative(KEY_TYPE), GUIContent.none);
                        }

                        using (var innerScope = Disposables.RectHorizontalScope(5, scope.GetNext(2))) {
                            var key     = property.GetTargetObjectOfProperty <AnimatorKey>();
                            var typeStr = GetDisplayString(key);
                            FoCsGUI.Label(innerScope.GetNext(2), LABEL);
                            FoCsGUI.PropertyField(innerScope.GetNext(3), property.FindPropertyRelative(typeStr), GUIContent.none);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static eInt DrawActionWithMenu(bool disabled, Rect position, Action <Rect> draw, GUICon label, GUICon[] Options, int active)
        {
            var propRect  = new Rect(position);
            var labelRect = new Rect(position);
            var menuRect  = new Rect(position);

            labelRect     = labelRect.Edit(RectEdit.SubtractY(1), RectEdit.SetWidth(EditorGUIUtility.labelWidth));
            menuRect.xMin = menuRect.xMax - MENU_BUTTON_SIZE;
            menuRect.xMax = position.xMax;
            propRect.xMin = labelRect.xMax;
            propRect.xMax = menuRect.xMin - 2;
            Label(labelRect, label);

            using (Disposables.DisabledScope(disabled))
                draw.Trigger(propRect);

            using (Disposables.SetIndent(0)) {
                var index = EditorGUI.Popup(menuRect, GUICon.none, active, Options, Styles.InLineOptionsMenu);

                return(GUIEvent.Create(position, index));
            }
        }
        protected virtual Rect DoGetNextAmount(int amount, Rect retVal)
        {
            retVal = retVal.Edit(RectEdit.SetWidth(retVal.width * amount));

            return(retVal);
        }
        private static int DoLessThen4Draw(Rect position, SerializedProperty property, int buttonsIntValue, float labelWidth, int enumLength, bool[] buttonPressed)
        {
            using (var scope = Disposables.RectHorizontalScope(enumLength, position.Edit(RectEdit.SetWidth(position.width - labelWidth), RectEdit.AddX(labelWidth)))) {
                for (var i = 0; i < enumLength; i++)
                {
                    // Check if the button is/was pressed
                    if ((property.intValue & 1 << i) == (1 << i))
                    {
                        buttonPressed[i] = true;
                    }

                    buttonPressed[i] = GUI.Toggle(scope.GetNext(), buttonPressed[i], property.enumNames[i], "Button");

                    if (buttonPressed[i])
                    {
                        buttonsIntValue += 1 << i;
                    }
                }
            }

            return(buttonsIntValue);
        }