Esempio n. 1
0
        /// <summary>
        /// (Re)creates all row GUI elements.
        /// </summary>
        internal protected void BuildGUI()
        {
            contentLayout.Clear();

            GUILayoutX externalTitleLayout = CreateGUI(contentLayout);

            if (localTitleLayout || (titleLayout != null && titleLayout == externalTitleLayout))
            {
                return;
            }

            if (externalTitleLayout != null)
            {
                localTitleLayout = false;
                titleLayout      = externalTitleLayout;
            }
            else
            {
                GUILayoutY buttonCenter = rowLayout.AddLayoutY();
                buttonCenter.AddFlexibleSpace();
                titleLayout = buttonCenter.AddLayoutX();
                buttonCenter.AddFlexibleSpace();

                localTitleLayout = true;
            }

            GUIContent cloneIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Clone),
                                                  new LocEdString("Clone"));
            GUIContent deleteIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Delete),
                                                   new LocEdString("Delete"));
            GUIContent moveUp = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.MoveUp),
                                               new LocEdString("Move up"));
            GUIContent moveDown = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.MoveDown),
                                                 new LocEdString("Move down"));

            GUIButton cloneBtn    = new GUIButton(cloneIcon, GUIOption.FixedWidth(30));
            GUIButton deleteBtn   = new GUIButton(deleteIcon, GUIOption.FixedWidth(30));
            GUIButton moveUpBtn   = new GUIButton(moveUp, GUIOption.FixedWidth(30));
            GUIButton moveDownBtn = new GUIButton(moveDown, GUIOption.FixedWidth(30));

            cloneBtn.OnClick    += () => parent.OnCloneButtonClicked(seqIndex);
            deleteBtn.OnClick   += () => parent.OnDeleteButtonClicked(seqIndex);
            moveUpBtn.OnClick   += () => parent.OnMoveUpButtonClicked(seqIndex);
            moveDownBtn.OnClick += () => parent.OnMoveDownButtonClicked(seqIndex);

            titleLayout.AddElement(cloneBtn);
            titleLayout.AddElement(deleteBtn);
            titleLayout.AddElement(moveUpBtn);
            titleLayout.AddElement(moveDownBtn);
        }
        /// <summary>
        /// (Re)creates all row GUI elements.
        /// </summary>
        internal protected void BuildGUI()
        {
            keyLayout.Clear();
            valueLayout.Clear();

            GUILayoutX externalTitleLayout = CreateKeyGUI(keyLayout);

            CreateValueGUI(valueLayout);
            if (localTitleLayout || (titleLayout != null && titleLayout == externalTitleLayout))
            {
                return;
            }

            if (externalTitleLayout != null)
            {
                localTitleLayout = false;
                titleLayout      = externalTitleLayout;
            }
            else
            {
                GUILayoutY buttonCenter = keyRowLayout.AddLayoutY();
                buttonCenter.AddFlexibleSpace();
                titleLayout = buttonCenter.AddLayoutX();
                buttonCenter.AddFlexibleSpace();

                localTitleLayout = true;
            }

            GUIContent cloneIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Clone),
                                                  new LocEdString("Clone"));
            GUIContent deleteIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Delete),
                                                   new LocEdString("Delete"));
            GUIContent editIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Edit),
                                                 new LocEdString("Edit"));

            cloneBtn  = new GUIButton(cloneIcon, GUIOption.FixedWidth(30));
            deleteBtn = new GUIButton(deleteIcon, GUIOption.FixedWidth(30));
            editBtn   = new GUIButton(editIcon, GUIOption.FixedWidth(30));

            cloneBtn.OnClick  += () => parent.OnCloneButtonClicked(rowIdx);
            deleteBtn.OnClick += () => parent.OnDeleteButtonClicked(rowIdx);
            editBtn.OnClick   += () => parent.OnEditButtonClicked(rowIdx);

            titleLayout.AddElement(cloneBtn);
            titleLayout.AddElement(deleteBtn);
            titleLayout.AddSpace(10);
            titleLayout.AddElement(editBtn);

            EditMode = editMode;
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a new material parameter GUI.
        /// </summary>
        /// <param name="shaderParam">Shader parameter to create the GUI for. Must be of color type.</param>
        /// <param name="material">Material the parameter is a part of.</param>
        /// <param name="layout">Layout to append the GUI elements to.</param>
        internal MaterialParamColorGUI(ShaderParameter shaderParam, Material material, GUILayout layout)
            : base(shaderParam)
        {
            LocString title = new LocEdString(shaderParam.name);

            var guiToggle = new GUIToggle(new GUIContent(
                                              EditorBuiltin.GetEditorToggleIcon(EditorToggleIcon.AnimateProperty), new LocString("Animate")));

            guiColor         = new GUIColorField(title);
            guiColorGradient = new GUIColorGradientField(title);

            bool isAnimated = material.IsAnimated(shaderParam.name);

            guiColor.Active         = !isAnimated;
            guiColorGradient.Active = isAnimated;

            fieldLayout = layout.AddLayoutX();
            fieldLayout.AddElement(guiColor);
            fieldLayout.AddElement(guiColorGradient);
            fieldLayout.AddSpace(10);
            fieldLayout.AddElement(guiToggle);

            guiColor.OnChanged += (x) =>
            {
                material.SetColor(shaderParam.name, x);
                EditorApplication.SetDirty(material);
            };

            guiColorGradient.OnChanged += x =>
            {
                material.SetColorGradient(shaderParam.name, x);
                EditorApplication.SetDirty(material);
            };

            guiToggle.OnToggled += x =>
            {
                guiColor.Active         = !x;
                guiColorGradient.Active = x;

                if (x)
                {
                    ColorGradient gradient = material.GetColorGradient(shaderParam.name);
                    if (gradient.NumKeys == 0)
                    {
                        material.SetColorGradient(shaderParam.name, new ColorGradient(material.GetColor(shaderParam.name)));
                    }
                }
            };
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a new material parameter GUI.
        /// </summary>
        /// <param name="shaderParam">Shader parameter to create the GUI for. Must be of floating point type.</param>
        /// <param name="material">Material the parameter is a part of.</param>
        /// <param name="layout">Layout to append the GUI elements to.</param>
        internal MaterialParamFloatGUI(ShaderParameter shaderParam, Material material, GUILayout layout)
            : base(shaderParam)
        {
            LocString title = new LocEdString(shaderParam.name);

            var guiToggle = new GUIToggle(new GUIContent(
                                              EditorBuiltin.GetEditorToggleIcon(EditorToggleIcon.AnimateProperty), new LocString("Animate")));

            guiConstant = new GUIFloatField(title);
            guiCurves   = new GUICurvesField(title);

            bool isAnimated = material.IsAnimated(shaderParam.name);

            guiConstant.Active = !isAnimated;
            guiCurves.Active   = isAnimated;

            fieldLayout = layout.AddLayoutX();
            fieldLayout.AddElement(guiConstant);
            fieldLayout.AddElement(guiCurves);
            fieldLayout.AddSpace(10);
            fieldLayout.AddElement(guiToggle);

            guiConstant.OnChanged += (x) =>
            {
                material.SetFloat(shaderParam.name, x);
                EditorApplication.SetDirty(material);
            };

            guiCurves.OnChanged += x =>
            {
                material.SetFloatCurve(shaderParam.name, x);
                EditorApplication.SetDirty(material);
            };

            guiToggle.OnToggled += x =>
            {
                guiConstant.Active = !x;
                guiCurves.Active   = x;
            };
        }
Esempio n. 5
0
        /// <summary>
        /// Registers a set of rows for all components in a <see cref="SceneObject"/>, as well as its transform and
        /// child objects.
        /// </summary>
        /// <param name="parent">Row element under which to create the new rows.</param>
        private void AddSceneObjectRows(Element parent)
        {
            string soName = "!" + parent.so.Name;

            Component[] components = parent.so.GetComponents();

            parent.children = new Element[components.Length + 2];

            SpriteTexture soIcon   = EditorBuiltin.GetEditorIcon(EditorIcon.SceneObject);
            SpriteTexture compIcon = EditorBuiltin.GetEditorIcon(EditorIcon.Component);

            // Add transform
            parent.children[0] = AddFoldoutRow(parent.childLayout, soIcon, "Transform", parent.so,
                                               null, parent.path + "/" + soName, ToggleTransformFoldout);

            // Add components
            for (int i = 0; i < components.Length; i++)
            {
                Component childComponent = components[i];
                Action <Element, bool> toggleCallback =
                    (toggleParent, expand) =>
                {
                    SerializableObject componentObject = new SerializableObject(childComponent.GetType(), childComponent);
                    ToggleObjectFoldout(toggleParent, componentObject, expand);
                };

                string name = childComponent.GetType().Name;
                string path = parent.path + "/" + soName + "/:" + name;
                parent.children[i + 1] = AddFoldoutRow(parent.childLayout, compIcon, name, parent.so, childComponent, path,
                                                       toggleCallback);
            }

            // Add children
            if (parent.so.GetNumChildren() > 0)
            {
                parent.children[parent.children.Length - 1] = AddFoldoutRow(parent.childLayout, soIcon, "Children",
                                                                            parent.so, null, parent.path + "/" + soName, ToggleChildFoldout);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Expands or collapses the set of rows displaying all <see cref="SceneObject"/> children of a
        /// <see cref="SceneObject"/>.
        /// </summary>
        /// <param name="parent">Parent row element whose children to expand/collapse.</param>
        /// <param name="expand">True to expand, false to collapse.</param>
        private void ToggleChildFoldout(Element parent, bool expand)
        {
            parent.childLayout.Clear();
            parent.children = null;

            parent.indentLayout.Active = expand;

            if (expand)
            {
                int numChildren = parent.so.GetNumChildren();

                parent.children = new Element[numChildren];

                for (int i = 0; i < numChildren; i++)
                {
                    SceneObject child = parent.so.GetChild(i);

                    SpriteTexture soIcon = EditorBuiltin.GetEditorIcon(EditorIcon.SceneObject);
                    parent.children[i] = AddFoldoutRow(parent.childLayout, soIcon, child.Name, child, null, parent.path,
                                                       ToggleSceneObjectFoldout);
                }
            }
        }
 private static void DrawIcon(ReflectionProbe reflProbe)
 {
     Gizmos.DrawIcon(reflProbe.SceneObject.Position,
                     EditorBuiltin.GetSceneViewIcon(SceneViewIcon.ReflectionProbe), false);
 }
Esempio n. 8
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);

                guiFoldout                 = new GUIToggle(title, EditorStyles.Foldout);
                guiFoldout.Value           = isExpanded;
                guiFoldout.AcceptsKeyFocus = false;
                guiFoldout.OnToggled      += x => ToggleFoldout(x, false);

                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
                    ? EditorStylesInternal.InspectorContentBgAlternate
                    : EditorStylesInternal.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;
                }
            }
        }
Esempio n. 9
0
 private static void DrawIcon(AudioListener listener)
 {
     Gizmos.DrawIcon(listener.SceneObject.Position,
                     EditorBuiltin.GetSceneViewIcon(SceneViewIcon.AudioListener), false);
 }
Esempio n. 10
0
        /// <summary>
        /// Rebuilds the GUI object header if needed.
        /// </summary>
        /// <param name="layoutIndex">Index at which to insert the GUI elements.</param>
        protected void BuildGUI(int layoutIndex)
        {
            Action BuildEmptyGUI = () =>
            {
                if (isInline)
                {
                    return;
                }

                guiInternalTitleLayout = guiTitleLayout.InsertLayoutX(0);

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

                if (!property.IsValueType)
                {
                    GUIContent createIcon = new GUIContent(EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Create),
                                                           new LocEdString("Create"));
                    guiCreateBtn          = new GUIButton(createIcon, GUIOption.FixedWidth(30));
                    guiCreateBtn.OnClick += OnCreateButtonClicked;
                    guiInternalTitleLayout.AddElement(guiCreateBtn);
                }
            };

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

                    GUIToggle guiFoldout = new GUIToggle(title, EditorStyles.Foldout);
                    guiFoldout.Value           = isExpanded;
                    guiFoldout.AcceptsKeyFocus = false;
                    guiFoldout.OnToggled      += OnFoldoutToggled;
                    guiInternalTitleLayout.AddElement(guiFoldout);

                    if (!style.StyleFlags.HasFlag(InspectableFieldStyleFlags.NotNull))
                    {
                        GUIContent clearIcon = new GUIContent(
                            EditorBuiltin.GetInspectorWindowIcon(InspectorWindowIcon.Clear),
                            new LocEdString("Clear"));
                        GUIButton clearBtn = new GUIButton(clearIcon, GUIOption.FixedWidth(20));
                        clearBtn.OnClick += OnClearButtonClicked;
                        guiInternalTitleLayout.AddElement(clearBtn);
                    }
                }

                if (isExpanded || isInline)
                {
                    SerializableObject  serializableObject = property.GetObject();
                    SerializableField[] fields             = serializableObject.Fields;

                    if (fields.Length > 0)
                    {
                        GUILayoutY guiContentLayout;
                        if (!isInline)
                        {
                            guiChildLayout = guiLayout.AddLayoutX();
                            guiChildLayout.AddSpace(IndentAmount);

                            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
                                ? EditorStylesInternal.InspectorContentBgAlternate
                                : EditorStylesInternal.InspectorContentBg;
                            GUIPanel   backgroundPanel    = guiContentPanel.AddPanel(backgroundDepth);
                            GUITexture inspectorContentBg = new GUITexture(null, bgPanelStyle);
                            backgroundPanel.AddElement(inspectorContentBg);
                        }
                        else
                        {
                            guiContentLayout = guiLayout;
                        }

                        children = CreateFields(serializableObject, context, path, depth + 1, guiContentLayout);
                    }
                }
                else
                {
                    guiChildLayout = null;
                }
            };

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

                    state = State.Empty;
                }
            }
            else if (state == State.Empty)
            {
                if (propertyValue != null)
                {
                    guiInternalTitleLayout?.Destroy();
                    guiInternalTitleLayout = null;
                    guiCreateBtn           = null;

                    BuildFilledGUI();
                    state = State.Filled;
                }
            }
            else if (state == State.Filled)
            {
                foreach (var child in children)
                {
                    child.Destroy();
                }

                children.Clear();

                guiInternalTitleLayout?.Destroy();
                guiInternalTitleLayout = null;
                guiCreateBtn           = null;

                if (guiChildLayout != null)
                {
                    guiChildLayout.Destroy();
                    guiChildLayout = null;
                }

                if (propertyValue == null)
                {
                    BuildEmptyGUI();
                    state = State.Empty;
                }
                else
                {
                    BuildFilledGUI();
                }
            }
        }
Esempio n. 11
0
        private void OnInitialize()
        {
            mainLayout = GUI.AddLayoutY();

            GUIContent viewIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.View),
                                                 new LocEdString("View"));
            GUIContent moveIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Move),
                                                 new LocEdString("Move"));
            GUIContent rotateIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Rotate),
                                                   new LocEdString("Rotate"));
            GUIContent scaleIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Scale),
                                                  new LocEdString("Scale"));

            GUIContent localIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Local),
                                                  new LocEdString("Local"));
            GUIContent worldIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.World),
                                                  new LocEdString("World"));

            GUIContent pivotIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Pivot),
                                                  new LocEdString("Pivot"));
            GUIContent centerIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Center),
                                                   new LocEdString("Center"));

            GUIContent moveSnapIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.MoveSnap),
                                                     new LocEdString("Move snap"));
            GUIContent rotateSnapIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.RotateSnap),
                                                       new LocEdString("Rotate snap"));

            GUIToggleGroup handlesTG = new GUIToggleGroup();

            viewButton   = new GUIToggle(viewIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            moveButton   = new GUIToggle(moveIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            rotateButton = new GUIToggle(rotateIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            scaleButton  = new GUIToggle(scaleIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));

            GUIToggleGroup coordModeTG = new GUIToggleGroup();

            localCoordButton = new GUIToggle(localIcon, coordModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(75));
            worldCoordButton = new GUIToggle(worldIcon, coordModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(75));

            GUIToggleGroup pivotModeTG = new GUIToggleGroup();

            pivotButton  = new GUIToggle(pivotIcon, pivotModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            centerButton = new GUIToggle(centerIcon, pivotModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));

            moveSnapButton = new GUIToggle(moveSnapIcon, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            moveSnapInput  = new GUIFloatField("", GUIOption.FlexibleWidth(35));

            rotateSnapButton = new GUIToggle(rotateSnapIcon, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            rotateSnapInput  = new GUIFloatField("", GUIOption.FlexibleWidth(35));

            GUIContent cameraOptionsIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.SceneCameraOptions), new LocEdString("Camera options"));

            cameraOptionsButton = new GUIButton(cameraOptionsIcon);

            viewButton.OnClick   += () => OnSceneToolButtonClicked(SceneViewTool.View);
            moveButton.OnClick   += () => OnSceneToolButtonClicked(SceneViewTool.Move);
            rotateButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Rotate);
            scaleButton.OnClick  += () => OnSceneToolButtonClicked(SceneViewTool.Scale);

            localCoordButton.OnClick += () => OnCoordinateModeButtonClicked(HandleCoordinateMode.Local);
            worldCoordButton.OnClick += () => OnCoordinateModeButtonClicked(HandleCoordinateMode.World);

            pivotButton.OnClick  += () => OnPivotModeButtonClicked(HandlePivotMode.Pivot);
            centerButton.OnClick += () => OnPivotModeButtonClicked(HandlePivotMode.Center);

            moveSnapButton.OnToggled += (bool active) => OnMoveSnapToggled(active);
            moveSnapInput.OnChanged  += (float value) => OnMoveSnapValueChanged(value);

            rotateSnapButton.OnToggled += (bool active) => OnRotateSnapToggled(active);
            rotateSnapInput.OnChanged  += (float value) => OnRotateSnapValueChanged(value);

            cameraOptionsButton.OnClick += () => OnCameraOptionsClicked();

            GUILayout handlesLayout = mainLayout.AddLayoutX();

            handlesLayout.AddElement(viewButton);
            handlesLayout.AddElement(moveButton);
            handlesLayout.AddElement(rotateButton);
            handlesLayout.AddElement(scaleButton);
            handlesLayout.AddSpace(10);
            handlesLayout.AddElement(localCoordButton);
            handlesLayout.AddElement(worldCoordButton);
            handlesLayout.AddSpace(10);
            handlesLayout.AddElement(pivotButton);
            handlesLayout.AddElement(centerButton);
            handlesLayout.AddFlexibleSpace();
            handlesLayout.AddElement(moveSnapButton);
            handlesLayout.AddElement(moveSnapInput);
            handlesLayout.AddSpace(10);
            handlesLayout.AddElement(rotateSnapButton);
            handlesLayout.AddElement(rotateSnapInput);
            handlesLayout.AddSpace(10);
            handlesLayout.AddElement(cameraOptionsButton);
            handlesLayout.SetHeight(viewButton.Bounds.height);

            GUIPanel mainPanel = mainLayout.AddPanel();

            rtPanel = mainPanel.AddPanel();

            // Loading progress
            loadLabel       = new GUILabel(new LocEdString("Loading scene..."));
            loadProgressBar = new GUIProgressBar("", GUIOption.FixedWidth(200));

            progressLayout = mainPanel.AddLayoutY();
            progressLayout.AddFlexibleSpace();
            GUILayout loadLabelLayout = progressLayout.AddLayoutX();

            loadLabelLayout.AddFlexibleSpace();
            loadLabelLayout.AddElement(loadLabel);
            loadLabelLayout.AddFlexibleSpace();

            GUILayout progressBarLayout = progressLayout.AddLayoutX();

            progressBarLayout.AddFlexibleSpace();
            progressBarLayout.AddElement(loadProgressBar);
            progressBarLayout.AddFlexibleSpace();
            progressLayout.AddFlexibleSpace();

            progressLayout.Active = false;

            selectionPanel = mainPanel.AddPanel(-1);

            sceneAxesPanel = mainPanel.AddPanel(-1);
            sceneAxesGUI   = new SceneAxesGUI(this, sceneAxesPanel, HandleAxesGUISize, HandleAxesGUISize, ProjectionType.Perspective);
            sceneAxesLastProjectionType = ProjectionType.Perspective;

            focusCatcher = new GUIButton("", EditorStyles.Blank);
            focusCatcher.OnFocusGained += () => hasContentFocus = true;
            focusCatcher.OnFocusLost   += () => hasContentFocus = false;

            GUIPanel focusPanel = GUI.AddPanel(-2);

            focusPanel.AddElement(focusCatcher);

            viewToolKey   = new VirtualButton(ViewToolBinding);
            moveToolKey   = new VirtualButton(MoveToolBinding);
            rotateToolKey = new VirtualButton(RotateToolBinding);
            scaleToolKey  = new VirtualButton(ScaleToolBinding);
            frameKey      = new VirtualButton(FrameBinding);

            UpdateRenderTexture(Width, Height - HeaderHeight);
            UpdateLoadingProgress();
        }
Esempio n. 12
0
 private static void DrawIcon(Decal decal)
 {
     Gizmos.DrawIcon(decal.SceneObject.Position,
                     EditorBuiltin.GetSceneViewIcon(SceneViewIcon.Decal), false);
 }
Esempio n. 13
0
        private void OnInitialize()
        {
            GUILayoutY layout      = GUI.AddLayoutY();
            GUILayoutX titleLayout = layout.AddLayoutX();

            GUIContentImages infoImages = new GUIContentImages(
                EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Info, 16, false),
                EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Info, 16, true));

            GUIContentImages warningImages = new GUIContentImages(
                EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Warning, 16, false),
                EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Warning, 16, true));

            GUIContentImages errorImages = new GUIContentImages(
                EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Error, 16, false),
                EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Error, 16, true));

            GUIToggle infoBtn    = new GUIToggle(new GUIContent(infoImages), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT));
            GUIToggle warningBtn = new GUIToggle(new GUIContent(warningImages), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT));
            GUIToggle errorBtn   = new GUIToggle(new GUIContent(errorImages), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT));

            GUIToggle detailsBtn     = new GUIToggle(new LocEdString("Show details"), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT));
            GUIButton clearBtn       = new GUIButton(new LocEdString("Clear"), GUIOption.FixedHeight(TITLE_HEIGHT));
            GUIToggle clearOnPlayBtn = new GUIToggle(new LocEdString("Clear on play"), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT));

            titleLayout.AddElement(infoBtn);
            titleLayout.AddElement(warningBtn);
            titleLayout.AddElement(errorBtn);
            titleLayout.AddFlexibleSpace();
            titleLayout.AddElement(detailsBtn);
            titleLayout.AddElement(clearBtn);
            titleLayout.AddElement(clearOnPlayBtn);

            infoBtn.Value    = filter.HasFlag(EntryFilter.Info);
            warningBtn.Value = filter.HasFlag(EntryFilter.Warning);
            errorBtn.Value   = filter.HasFlag(EntryFilter.Error);

            clearOnPlayBtn.Value = EditorSettings.GetBool(CLEAR_ON_PLAY_KEY, true);

            infoBtn.OnToggled += x =>
            {
                if (x)
                {
                    SetFilter(filter | EntryFilter.Info);
                }
                else
                {
                    SetFilter(filter & ~EntryFilter.Info);
                }
            };

            warningBtn.OnToggled += x =>
            {
                if (x)
                {
                    SetFilter(filter | EntryFilter.Warning);
                }
                else
                {
                    SetFilter(filter & ~EntryFilter.Warning);
                }
            };

            errorBtn.OnToggled += x =>
            {
                if (x)
                {
                    SetFilter(filter | EntryFilter.Error);
                }
                else
                {
                    SetFilter(filter & ~EntryFilter.Error);
                }
            };

            detailsBtn.OnToggled     += ToggleDetailsPanel;
            clearBtn.OnClick         += ClearLog;
            clearOnPlayBtn.OnToggled += ToggleClearOnPlay;

            GUILayoutX mainLayout = layout.AddLayoutX();

            listView = new GUIListView <ConsoleGUIEntry, ConsoleEntryData>(Width, ListHeight, ENTRY_HEIGHT, mainLayout);

            detailsSeparator = new GUITexture(Builtin.WhiteTexture, GUIOption.FixedWidth(SEPARATOR_WIDTH));
            detailsArea      = new GUIScrollArea(ScrollBarType.ShowIfDoesntFit, ScrollBarType.NeverShow);
            mainLayout.AddElement(detailsSeparator);
            mainLayout.AddElement(detailsArea);
            detailsSeparator.Active = false;
            detailsArea.Active      = false;

            detailsSeparator.SetTint(SEPARATOR_COLOR);

            Refresh();
            Debug.OnAdded += OnEntryAdded;
        }
Esempio n. 14
0
 private static void DrawIcon(LightProbeVolume volume)
 {
     Gizmos.DrawIcon(volume.SceneObject.Position,
                     EditorBuiltin.GetSceneViewIcon(SceneViewIcon.LightProbes), false);
 }
Esempio n. 15
0
 private static void DrawIcon(AudioSource source)
 {
     Gizmos.DrawIcon(source.SceneObject.Position,
                     EditorBuiltin.GetSceneViewIcon(SceneViewIcon.AudioSource), false);
 }
 private static void DrawIcon(ParticleSystem component)
 {
     Gizmos.DrawIcon(component.SceneObject.Position, EditorBuiltin.GetSceneViewIcon(SceneViewIcon.ParticleSystem), false);
 }
        /// <summary>
        /// Returns an icon that can be used for displaying a resource of the specified type.
        /// </summary>
        /// <param name="path">Path to the project library entry to display data for.</param>
        /// <param name="size">Size of the icon to retrieve, in pixels.</param>
        /// <returns>Icon to display for the specified entry.</returns>
        private static SpriteTexture GetIcon(string path, int size)
        {
            LibraryEntry entry = ProjectLibrary.GetEntry(path);

            if (entry.Type == LibraryEntryType.Directory)
            {
                return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.Folder, size));
            }
            else
            {
                ResourceMeta         meta  = ProjectLibrary.GetMeta(path);
                ProjectResourceIcons icons = meta.Icons;

                RRef <Texture> icon;
                if (size <= 16)
                {
                    icon = icons.icon16;
                }
                else if (size <= 32)
                {
                    icon = icons.icon32;
                }
                else if (size <= 48)
                {
                    icon = icons.icon48;
                }
                else
                {
                    icon = icons.icon64;
                }

                if (icon.Value != null)
                {
                    return(new SpriteTexture(icon));
                }

                switch (meta.ResType)
                {
                case ResourceType.Font:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.Font, size));

                case ResourceType.Mesh:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.Mesh, size));

                case ResourceType.Texture:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.Texture, size));

                case ResourceType.PlainText:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.PlainText, size));

                case ResourceType.ScriptCode:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.ScriptCode, size));

                case ResourceType.SpriteTexture:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.SpriteTexture, size));

                case ResourceType.Shader:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.Shader, size));

                case ResourceType.ShaderInclude:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.Shader, size));

                case ResourceType.Material:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.Material, size));

                case ResourceType.Prefab:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.Prefab, size));

                case ResourceType.GUISkin:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.GUISkin, size));

                case ResourceType.PhysicsMaterial:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.PhysicsMaterial, size));

                case ResourceType.PhysicsMesh:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.PhysicsMesh, size));

                case ResourceType.AudioClip:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.AudioClip, size));

                case ResourceType.AnimationClip:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.AnimationClip, size));

                case ResourceType.VectorField:
                    return(EditorBuiltin.GetProjectLibraryIcon(ProjectLibraryIcon.VectorField, size));
                }
            }

            return(null);
        }
Esempio n. 18
0
            /// <inheritdoc/>
            public override void UpdateContents(int index, ConsoleEntryData data)
            {
                if (index != sSelectedElementIdx)
                {
                    if (index % 2 != 0)
                    {
                        background.Visible = true;
                        background.SetTint(BG_COLOR);
                    }
                    else
                    {
                        background.Visible = false;
                    }
                }
                else
                {
                    background.Visible = true;
                    background.SetTint(SELECTION_COLOR);
                }

                switch (data.type)
                {
                case DebugMessageType.Info:
                    icon.SetTexture(EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Info, 32, false));
                    break;

                case DebugMessageType.Warning:
                case DebugMessageType.CompilerWarning:
                    icon.SetTexture(EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Warning, 32, false));
                    break;

                case DebugMessageType.Error:
                case DebugMessageType.CompilerError:
                    icon.SetTexture(EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Error, 32, false));
                    break;
                }

                messageLabel.SetContent(new LocEdString(data.message));

                string method = "";

                if (data.callstack != null && data.callstack.Length > 0)
                {
                    string filePath        = data.callstack[0].file;
                    bool   isFilePathValid = filePath.IndexOfAny(Path.GetInvalidPathChars()) == -1;

                    if (isFilePathValid)
                    {
                        file = Path.GetFileName(data.callstack[0].file);
                    }
                    else
                    {
                        file = "<unknown file>";
                    }

                    line = data.callstack[0].line;

                    if (string.IsNullOrEmpty(data.callstack[0].method))
                    {
                        method = "\tin " + file + ":" + line;
                    }
                    else
                    {
                        method = "\t" + data.callstack[0].method + " in " + file + ":" + line;
                    }
                }
                else
                {
                    file = "";
                    line = 0;
                }

                functionLabel.SetContent(new LocEdString(method));

                entryIdx = index;
            }
Esempio n. 19
0
 private static void DrawIcon(Light light)
 {
     Gizmos.DrawIcon(light.SceneObject.Position, EditorBuiltin.GetSceneViewIcon(SceneViewIcon.Light), false);
 }
Esempio n. 20
0
        /// <summary>
        /// Sets a scene object whose GUI is to be displayed in the inspector. Clears any previous contents of the window.
        /// </summary>
        /// <param name="so">Scene object to inspect.</param>
        private void SetObjectToInspect(SceneObject so)
        {
            if (so == null)
            {
                return;
            }

            currentType = InspectorType.SceneObject;
            activeSO    = so;

            inspectorScrollArea = new GUIScrollArea(ScrollBarType.ShowIfDoesntFit, ScrollBarType.NeverShow);
            scrollAreaHighlight = new GUITexture(Builtin.WhiteTexture);
            scrollAreaHighlight.SetTint(HIGHLIGHT_COLOR);
            scrollAreaHighlight.Active = false;

            GUI.AddElement(inspectorScrollArea);
            GUIPanel inspectorPanel = inspectorScrollArea.Layout.AddPanel();

            inspectorLayout = inspectorPanel.AddLayoutY();
            highlightPanel  = inspectorPanel.AddPanel(-1);
            highlightPanel.AddElement(scrollAreaHighlight);

            // SceneObject fields
            CreateSceneObjectFields();
            RefreshSceneObjectFields(true);

            // Components
            Component[] allComponents = so.GetComponents();
            for (int i = 0; i < allComponents.Length; i++)
            {
                inspectorLayout.AddSpace(COMPONENT_SPACING);

                InspectorComponent data = new InspectorComponent();
                data.instanceId = allComponents[i].InstanceId;
                data.folded     = false;

                data.foldout = new GUIToggle(allComponents[i].GetType().Name, EditorStyles.Foldout);
                data.foldout.AcceptsKeyFocus = false;

                SpriteTexture xBtnIcon = EditorBuiltin.GetEditorIcon(EditorIcon.X);
                data.removeBtn = new GUIButton(new GUIContent(xBtnIcon), GUIOption.FixedWidth(30));

                data.title = inspectorLayout.AddLayoutX();
                data.title.AddElement(data.foldout);
                data.title.AddElement(data.removeBtn);
                data.panel = inspectorLayout.AddPanel();

                var persistentProperties = persistentData.GetProperties(allComponents[i].InstanceId);

                data.inspector = InspectorUtility.GetInspector(allComponents[i].GetType());
                data.inspector.Initialize(data.panel, allComponents[i], persistentProperties);

                bool isExpanded = data.inspector.Persistent.GetBool(data.instanceId + "_Expanded", true);
                data.foldout.Value = isExpanded;

                if (!isExpanded)
                {
                    data.inspector.SetVisible(false);
                }

                Type curComponentType = allComponents[i].GetType();
                data.foldout.OnToggled += (bool expanded) => OnComponentFoldoutToggled(data, expanded);
                data.removeBtn.OnClick += () => OnComponentRemoveClicked(curComponentType);

                inspectorComponents.Add(data);
            }

            inspectorLayout.AddFlexibleSpace();

            UpdateDropAreas();
        }
 private static void DrawIcon(Camera camera)
 {
     Gizmos.DrawIcon(camera.SceneObject.Position, EditorBuiltin.GetSceneViewIcon(SceneViewIcon.Camera), false);
 }