Exemple #1
0
        /// <inheritdoc/>
        protected internal override void Initialize(int layoutIndex)
        {
            if (property != null)
            {
                guiIntField = new GUIIntField(new GUIContent(title));
                if (style != null)
                {
                    if (style.StepStyle != null && style.StepStyle.Step != 0)
                    {
                        guiIntField.Step = (int)style.StepStyle.Step;
                    }
                    if (style.RangeStyle != null)
                    {
                        guiIntField.SetRange((int)style.RangeStyle.Min, (int)style.RangeStyle.Max);
                    }
                }
                guiIntField.OnChanged   += OnFieldValueChanged;
                guiIntField.OnConfirmed += OnFieldValueConfirm;
                guiIntField.OnFocusLost += OnFieldValueConfirm;

                layout.AddElement(layoutIndex, guiIntField);
            }
        }
Exemple #2
0
        /// <summary>
        /// Rebuilds the GUI list header if needed.
        /// </summary>
        protected void UpdateHeaderGUI()
        {
            Action BuildEmptyGUI = () =>
            {
                guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0);

                guiInternalTitleLayout.AddElement(new GUILabel(title));
                guiInternalTitleLayout.AddElement(new GUILabel("Empty", GUIOption.FixedWidth(100)));

                GUIContent createIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Create),
                                                       new LocEdString("Create"));
                GUIButton createBtn = new GUIButton(createIcon, GUIOption.FixedWidth(30));
                createBtn.OnClick += OnCreateButtonClicked;
                guiInternalTitleLayout.AddElement(createBtn);
            };

            Action BuildFilledGUI = () =>
            {
                guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0);

                GUIToggle guiFoldout = new GUIToggle(title, EditorStyles.Foldout);
                guiFoldout.Value      = isExpanded;
                guiFoldout.OnToggled += ToggleFoldout;
                guiSizeField          = new GUIIntField("", GUIOption.FixedWidth(50));
                guiSizeField.SetRange(0, int.MaxValue);

                GUIContent resizeIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Resize),
                                                       new LocEdString("Resize"));
                GUIButton guiResizeBtn = new GUIButton(resizeIcon, GUIOption.FixedWidth(30));
                guiResizeBtn.OnClick += OnResizeButtonClicked;

                GUIContent clearIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Clear),
                                                      new LocEdString("Clear"));
                GUIButton guiClearBtn = new GUIButton(clearIcon, GUIOption.FixedWidth(30));
                guiClearBtn.OnClick += OnClearButtonClicked;

                guiInternalTitleLayout.AddElement(guiFoldout);
                guiInternalTitleLayout.AddElement(guiSizeField);
                guiInternalTitleLayout.AddElement(guiResizeBtn);
                guiInternalTitleLayout.AddElement(guiClearBtn);

                guiSizeField.Value = GetNumRows();

                guiChildLayout = guiLayout.AddLayoutX();
                guiChildLayout.AddSpace(IndentAmount);
                guiChildLayout.Active = isExpanded;

                GUIPanel   guiContentPanel  = guiChildLayout.AddPanel();
                GUILayoutX guiIndentLayoutX = guiContentPanel.AddLayoutX();
                guiIndentLayoutX.AddSpace(IndentAmount);
                GUILayoutY guiIndentLayoutY = guiIndentLayoutX.AddLayoutY();
                guiIndentLayoutY.AddSpace(IndentAmount);
                guiContentLayout = guiIndentLayoutY.AddLayoutY();
                guiIndentLayoutY.AddSpace(IndentAmount);
                guiIndentLayoutX.AddSpace(IndentAmount);
                guiChildLayout.AddSpace(IndentAmount);

                short  backgroundDepth = (short)(Inspector.START_BACKGROUND_DEPTH - depth - 1);
                string bgPanelStyle    = depth % 2 == 0
                    ? EditorStyles.InspectorContentBgAlternate
                    : EditorStyles.InspectorContentBg;

                GUIPanel   backgroundPanel    = guiContentPanel.AddPanel(backgroundDepth);
                GUITexture inspectorContentBg = new GUITexture(null, bgPanelStyle);
                backgroundPanel.AddElement(inspectorContentBg);
            };

            if (state == State.None)
            {
                if (!IsNull())
                {
                    BuildFilledGUI();
                    state = State.Filled;
                }
                else
                {
                    BuildEmptyGUI();

                    state = State.Empty;
                }
            }
            else if (state == State.Empty)
            {
                if (!IsNull())
                {
                    guiInternalTitleLayout.Destroy();
                    BuildFilledGUI();
                    state = State.Filled;
                }
            }
            else if (state == State.Filled)
            {
                if (IsNull())
                {
                    guiInternalTitleLayout.Destroy();
                    guiChildLayout.Destroy();
                    BuildEmptyGUI();

                    state = State.Empty;
                }
            }
        }
Exemple #3
0
            /// <inheritdoc/>
            protected override GUILayoutX CreateGUI(GUILayoutY layout)
            {
                AnimationSplitInfo rowSplitInfo = GetValue <AnimationSplitInfo>();

                if (rowSplitInfo == null)
                {
                    rowSplitInfo = new AnimationSplitInfo();
                    SetValue(rowSplitInfo);
                }

                GUILayoutX titleLayout   = layout.AddLayoutX();
                GUILayoutX contentLayout = layout.AddLayoutX();

                GUILabel title = new GUILabel(new LocEdString(SeqIndex + ". "));

                nameField       = new GUITextField(new LocEdString("Name"), 40, false, "", GUIOption.FixedWidth(160));
                startFrameField = new GUIIntField(new LocEdString("Start"), 40, "", GUIOption.FixedWidth(80));
                endFrameField   = new GUIIntField(new LocEdString("End"), 40, "", GUIOption.FixedWidth(80));
                isAdditiveField = new GUIToggleField(new LocEdString("Is additive"), 50, "", GUIOption.FixedWidth(80));

                startFrameField.SetRange(0, int.MaxValue);
                endFrameField.SetRange(0, int.MaxValue);

                titleLayout.AddElement(title);
                titleLayout.AddElement(nameField);
                titleLayout.AddFlexibleSpace();
                contentLayout.AddSpace(10);
                contentLayout.AddElement(startFrameField);
                contentLayout.AddSpace(5);
                contentLayout.AddElement(endFrameField);
                contentLayout.AddSpace(5);
                contentLayout.AddElement(isAdditiveField);

                nameField.OnChanged += x =>
                {
                    AnimationSplitInfo splitInfo = GetValue <AnimationSplitInfo>();
                    splitInfo.name = x;

                    MarkAsModified();
                };

                nameField.OnFocusLost += ConfirmModify;
                nameField.OnConfirmed += ConfirmModify;

                startFrameField.OnChanged += x =>
                {
                    AnimationSplitInfo splitInfo = GetValue <AnimationSplitInfo>();
                    splitInfo.startFrame = x;

                    MarkAsModified();
                };

                startFrameField.OnFocusLost += ConfirmModify;
                startFrameField.OnConfirmed += ConfirmModify;

                endFrameField.OnChanged += x =>
                {
                    AnimationSplitInfo splitInfo = GetValue <AnimationSplitInfo>();
                    splitInfo.endFrame = x;

                    MarkAsModified();
                };

                endFrameField.OnFocusLost += ConfirmModify;
                endFrameField.OnConfirmed += ConfirmModify;

                isAdditiveField.OnChanged += x =>
                {
                    AnimationSplitInfo splitInfo = GetValue <AnimationSplitInfo>();
                    splitInfo.isAdditive = x;

                    MarkAsModified();
                    ConfirmModify();
                };

                return(titleLayout);
            }
        private void OnInitialize()
        {
            guiColor = new GUIColorField("", GUIOption.FixedWidth(100));
            guiSlider2DTex = new GUITexture(null, GUIOption.FixedHeight(ColorBoxHeight), GUIOption.FixedWidth(ColorBoxWidth));
            guiSliderVertTex = new GUITexture(null, GUIOption.FixedHeight(SliderSideHeight), GUIOption.FixedWidth(SliderSideWidth));
            guiSliderRHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));
            guiSliderGHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));
            guiSliderBHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));
            guiSliderAHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));

            guiColorBoxBtn = new GUIButton(colorBoxMode.ToString());
            guiColorModeBtn = new GUIButton(sliderMode.ToString());

            guiSliderVert = new GUISliderV(EditorStylesInternal.ColorSliderVert);
            guiSliderRHorz = new GUISliderH(EditorStylesInternal.ColorSliderHorz);
            guiSliderGHorz = new GUISliderH(EditorStylesInternal.ColorSliderHorz);
            guiSliderBHorz = new GUISliderH(EditorStylesInternal.ColorSliderHorz);
            guiSliderAHorz = new GUISliderH(EditorStylesInternal.ColorSliderHorz);
            guiSlider2DHandle = new GUITexture(null, EditorStylesInternal.ColorSlider2DHandle);

            guiLabelR = new GUILabel(new LocEdString("R"));
            guiLabelG = new GUILabel(new LocEdString("G"));
            guiLabelB = new GUILabel(new LocEdString("B"));
            guiLabelA = new GUILabel(new LocEdString("A"));

            guiInputR = new GUIIntField();
            guiInputG = new GUIIntField();
            guiInputB = new GUIIntField();
            guiInputA = new GUIIntField();

            guiOK = new GUIButton(new LocEdString("OK"));
            guiCancel = new GUIButton(new LocEdString("Cancel"));

            guiColorBoxBtn.OnClick += OnColorBoxModeChanged;
            guiColorModeBtn.OnClick += OnSliderModeChanged;

            guiSliderVert.OnChanged += OnSliderVertChanged;
            guiSliderRHorz.OnChanged += OnSliderRHorzChanged;
            guiSliderGHorz.OnChanged += OnSliderGHorzChanged;
            guiSliderBHorz.OnChanged += OnSliderBHorzChanged;
            guiSliderAHorz.OnChanged += OnSliderAHorzChanged;

            guiInputR.OnChanged += OnInputRChanged;
            guiInputG.OnChanged += OnInputGChanged;
            guiInputB.OnChanged += OnInputBChanged;
            guiInputA.OnChanged += OnInputAChanged;

            guiOK.OnClick += OnOK;
            guiCancel.OnClick += OnCancel;

            GUIPanel mainPanel = GUI.AddPanel(0);
            GUILayout v0 = mainPanel.AddLayoutY();

            v0.AddSpace(5);

            GUILayout h0 = v0.AddLayoutX();
            h0.AddSpace(10);
            h0.AddElement(guiColor);
            h0.AddFlexibleSpace();
            h0.AddElement(guiColorBoxBtn);
            h0.AddElement(guiColorModeBtn);
            h0.AddSpace(10);

            v0.AddSpace(10);

            GUILayout h1 = v0.AddLayoutX();
            h1.AddSpace(10);
            h1.AddElement(guiSlider2DTex);
            h1.AddFlexibleSpace();
            h1.AddElement(guiSliderVertTex);
            h1.AddSpace(10);

            v0.AddSpace(10);

            GUILayout h2 = v0.AddLayoutX();
            h2.AddSpace(10);
            h2.AddElement(guiLabelR);
            h2.AddFlexibleSpace();
            h2.AddElement(guiSliderRHorzTex);
            h2.AddFlexibleSpace();
            h2.AddElement(guiInputR);
            h2.AddSpace(10);

            v0.AddSpace(5);

            GUILayout h3 = v0.AddLayoutX();
            h3.AddSpace(10);
            h3.AddElement(guiLabelG);
            h3.AddFlexibleSpace();
            h3.AddElement(guiSliderGHorzTex);
            h3.AddFlexibleSpace();
            h3.AddElement(guiInputG);
            h3.AddSpace(10);

            v0.AddSpace(5);

            GUILayout h4 = v0.AddLayoutX();
            h4.AddSpace(10);
            h4.AddElement(guiLabelB);
            h4.AddFlexibleSpace();
            h4.AddElement(guiSliderBHorzTex);
            h4.AddFlexibleSpace();
            h4.AddElement(guiInputB);
            h4.AddSpace(10);

            v0.AddSpace(5);

            GUILayout h5 = v0.AddLayoutX();
            h5.AddSpace(10);
            h5.AddElement(guiLabelA);
            h5.AddFlexibleSpace();
            h5.AddElement(guiSliderAHorzTex);
            h5.AddFlexibleSpace();
            h5.AddElement(guiInputA);
            h5.AddSpace(10);

            v0.AddSpace(10);

            GUILayout h6 = v0.AddLayoutX();
            h6.AddFlexibleSpace();
            h6.AddElement(guiOK);
            h6.AddSpace(10);
            h6.AddElement(guiCancel);
            h6.AddFlexibleSpace();

            v0.AddSpace(5);

            GUIPanel overlay = GUI.AddPanel(-1);
            overlay.SetWidth(Width);
            overlay.SetHeight(Height);

            overlay.AddElement(guiSliderVert);
            overlay.AddElement(guiSliderRHorz);
            overlay.AddElement(guiSliderGHorz);
            overlay.AddElement(guiSliderBHorz);
            overlay.AddElement(guiSliderAHorz);
            overlay.AddElement(guiSlider2DHandle);

            colorBox = new ColorSlider2D(guiSlider2DTex, guiSlider2DHandle, ColorBoxWidth, ColorBoxHeight);
            sideSlider = new ColorSlider1DVert(guiSliderVertTex, guiSliderVert, SliderSideWidth, SliderSideHeight);

            sliderR = new ColorSlider1DHorz(guiSliderRHorzTex, guiSliderRHorz, SliderIndividualWidth, SliderIndividualHeight);
            sliderG = new ColorSlider1DHorz(guiSliderGHorzTex, guiSliderGHorz, SliderIndividualWidth, SliderIndividualHeight);
            sliderB = new ColorSlider1DHorz(guiSliderBHorzTex, guiSliderBHorz, SliderIndividualWidth, SliderIndividualHeight);
            sliderA = new ColorSlider1DHorz(guiSliderAHorzTex, guiSliderAHorz, SliderIndividualWidth, SliderIndividualHeight);

            colorBox.OnValueChanged += OnColorBoxValueChanged;

            Color startA = new Color(0, 0, 0, 1);
            Color stepA = new Color(1, 1, 1, 0);
            sliderA.UpdateTexture(startA, stepA, false);
            guiInputA.SetRange(0, 255);
            guiInputA.Value = 255;
            guiSliderAHorz.Percent = 1.0f;

            guiColor.Value = SelectedColor;
            UpdateInputBoxValues();
            Update2DSliderValues();
            Update1DSliderValues();
            UpdateSliderMode();
            Update2DSliderTextures();
            Update1DSliderTextures();
        }
Exemple #5
0
        private void OnInitialize()
        {
            guiColor          = new GUIColorField("", GUIOption.FixedWidth(100));
            guiSlider2DTex    = new GUITexture(null, GUIOption.FixedHeight(ColorBoxHeight), GUIOption.FixedWidth(ColorBoxWidth));
            guiSliderVertTex  = new GUITexture(null, GUIOption.FixedHeight(SliderSideHeight), GUIOption.FixedWidth(SliderSideWidth));
            guiSliderRHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));
            guiSliderGHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));
            guiSliderBHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));
            guiSliderAHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));

            guiColorBoxBtn  = new GUIButton(colorBoxMode.ToString());
            guiColorModeBtn = new GUIButton(sliderMode.ToString());

            guiSliderVert     = new GUISliderV(EditorStyles.ColorSliderVert);
            guiSliderRHorz    = new GUISliderH(EditorStyles.ColorSliderHorz);
            guiSliderGHorz    = new GUISliderH(EditorStyles.ColorSliderHorz);
            guiSliderBHorz    = new GUISliderH(EditorStyles.ColorSliderHorz);
            guiSliderAHorz    = new GUISliderH(EditorStyles.ColorSliderHorz);
            guiSlider2DHandle = new GUITexture(null, EditorStyles.ColorSlider2DHandle);

            guiLabelR = new GUILabel(new LocEdString("R"));
            guiLabelG = new GUILabel(new LocEdString("G"));
            guiLabelB = new GUILabel(new LocEdString("B"));
            guiLabelA = new GUILabel(new LocEdString("A"));

            guiInputR = new GUIIntField();
            guiInputG = new GUIIntField();
            guiInputB = new GUIIntField();
            guiInputA = new GUIIntField();

            guiOK     = new GUIButton(new LocEdString("OK"));
            guiCancel = new GUIButton(new LocEdString("Cancel"));

            guiColorBoxBtn.OnClick  += OnColorBoxModeChanged;
            guiColorModeBtn.OnClick += OnSliderModeChanged;

            guiSliderVert.OnChanged  += OnSliderVertChanged;
            guiSliderRHorz.OnChanged += OnSliderRHorzChanged;
            guiSliderGHorz.OnChanged += OnSliderGHorzChanged;
            guiSliderBHorz.OnChanged += OnSliderBHorzChanged;
            guiSliderAHorz.OnChanged += OnSliderAHorzChanged;

            guiInputR.OnChanged += OnInputRChanged;
            guiInputG.OnChanged += OnInputGChanged;
            guiInputB.OnChanged += OnInputBChanged;
            guiInputA.OnChanged += OnInputAChanged;

            guiOK.OnClick     += OnOK;
            guiCancel.OnClick += OnCancel;

            GUIPanel  mainPanel = GUI.AddPanel(0);
            GUILayout v0        = mainPanel.AddLayoutY();

            v0.AddSpace(5);

            GUILayout h0 = v0.AddLayoutX();

            h0.AddSpace(10);
            h0.AddElement(guiColor);
            h0.AddFlexibleSpace();
            h0.AddElement(guiColorBoxBtn);
            h0.AddElement(guiColorModeBtn);
            h0.AddSpace(10);

            v0.AddSpace(10);

            GUILayout h1 = v0.AddLayoutX();

            h1.AddSpace(10);
            h1.AddElement(guiSlider2DTex);
            h1.AddFlexibleSpace();
            h1.AddElement(guiSliderVertTex);
            h1.AddSpace(10);

            v0.AddSpace(10);

            GUILayout h2 = v0.AddLayoutX();

            h2.AddSpace(10);
            h2.AddElement(guiLabelR);
            h2.AddFlexibleSpace();
            h2.AddElement(guiSliderRHorzTex);
            h2.AddFlexibleSpace();
            h2.AddElement(guiInputR);
            h2.AddSpace(10);

            v0.AddSpace(5);

            GUILayout h3 = v0.AddLayoutX();

            h3.AddSpace(10);
            h3.AddElement(guiLabelG);
            h3.AddFlexibleSpace();
            h3.AddElement(guiSliderGHorzTex);
            h3.AddFlexibleSpace();
            h3.AddElement(guiInputG);
            h3.AddSpace(10);

            v0.AddSpace(5);

            GUILayout h4 = v0.AddLayoutX();

            h4.AddSpace(10);
            h4.AddElement(guiLabelB);
            h4.AddFlexibleSpace();
            h4.AddElement(guiSliderBHorzTex);
            h4.AddFlexibleSpace();
            h4.AddElement(guiInputB);
            h4.AddSpace(10);

            v0.AddSpace(5);

            GUILayout h5 = v0.AddLayoutX();

            h5.AddSpace(10);
            h5.AddElement(guiLabelA);
            h5.AddFlexibleSpace();
            h5.AddElement(guiSliderAHorzTex);
            h5.AddFlexibleSpace();
            h5.AddElement(guiInputA);
            h5.AddSpace(10);

            v0.AddSpace(10);

            GUILayout h6 = v0.AddLayoutX();

            h6.AddFlexibleSpace();
            h6.AddElement(guiOK);
            h6.AddSpace(10);
            h6.AddElement(guiCancel);
            h6.AddFlexibleSpace();

            v0.AddSpace(5);

            GUIPanel overlay = GUI.AddPanel(-1);

            overlay.SetWidth(Width);
            overlay.SetHeight(Height);

            overlay.AddElement(guiSliderVert);
            overlay.AddElement(guiSliderRHorz);
            overlay.AddElement(guiSliderGHorz);
            overlay.AddElement(guiSliderBHorz);
            overlay.AddElement(guiSliderAHorz);
            overlay.AddElement(guiSlider2DHandle);

            colorBox   = new ColorSlider2D(guiSlider2DTex, guiSlider2DHandle, ColorBoxWidth, ColorBoxHeight);
            sideSlider = new ColorSlider1DVert(guiSliderVertTex, guiSliderVert, SliderSideWidth, SliderSideHeight);

            sliderR = new ColorSlider1DHorz(guiSliderRHorzTex, guiSliderRHorz, SliderIndividualWidth, SliderIndividualHeight);
            sliderG = new ColorSlider1DHorz(guiSliderGHorzTex, guiSliderGHorz, SliderIndividualWidth, SliderIndividualHeight);
            sliderB = new ColorSlider1DHorz(guiSliderBHorzTex, guiSliderBHorz, SliderIndividualWidth, SliderIndividualHeight);
            sliderA = new ColorSlider1DHorz(guiSliderAHorzTex, guiSliderAHorz, SliderIndividualWidth, SliderIndividualHeight);

            colorBox.OnValueChanged += OnColorBoxValueChanged;

            Color startA = new Color(0, 0, 0, 1);
            Color stepA  = new Color(1, 1, 1, 0);

            sliderA.UpdateTexture(startA, stepA, false);
            guiInputA.SetRange(0, 255);
            guiInputA.Value        = 255;
            guiSliderAHorz.Percent = 1.0f;

            guiColor.Value = SelectedColor;
            UpdateInputBoxValues();
            Update2DSliderValues();
            Update1DSliderValues();
            UpdateSliderMode();
            Update2DSliderTextures();
            Update1DSliderTextures();
        }