コード例 #1
0
ファイル: Toolbar.cs プロジェクト: runewather/AstilaQuest
        private void RenderButton(int buttonIndex)
        {
            EditorGUIColor.Push(GetButtonColor(buttonIndex));

            Texture2D buttonTexture = GetButtonTexture(buttonIndex);
            var       buttonContent = new GUIContent();

            buttonContent.text    = "";
            buttonContent.image   = buttonTexture;
            buttonContent.tooltip = _buttonTooltips[buttonIndex];

            if (_useBoxStyleForButtons)
            {
                if (GUILayout.Button(buttonContent, "Box", GUILayout.Width(buttonTexture.width * _buttonScale), GUILayout.Height(buttonTexture.height * _buttonScale), GUILayout.ExpandWidth(false)))
                {
                    HandleButtonClick(buttonIndex);
                }
            }
            else
            {
                if (GUILayout.Button(buttonContent, GUILayout.Width(buttonTexture.width * _buttonScale), GUILayout.Height(buttonTexture.height * _buttonScale), GUILayout.ExpandWidth(false)))
                {
                    HandleButtonClick(buttonIndex);
                }
            }
            EditorGUIColor.Pop();
        }
コード例 #2
0
 private void RenderBeginInteractionSessionButton()
 {
     EditorGUIColor.Push(_mirror.IsInteractionSessionActive ? Color.green : Color.white);
     if (GUILayout.Button(GetContentForBeginInteractionSessionButton(), GUILayout.Width(EditorGUILayoutEx.PreferedActionButtonWidth * 0.4f)))
     {
         _mirror.ToggleInteractionSession();
     }
     EditorGUIColor.Pop();
 }
コード例 #3
0
 private void RenderPatternActivationButton()
 {
     EditorGUIColor.Push(GetPatternActivationButtonColor());
     if (GUILayout.Button(GetContentForPatternActivationButton(), GetStyleForPatternActivationButton(), GUILayout.ExpandWidth(true)))
     {
         UndoEx.RecordForToolAction(ObjectPlacementPathHeightPatternDatabase.Get());
         ObjectPlacementPathHeightPatternDatabase.Get().SetActivePattern(_heightPattern);
     }
     EditorGUIColor.Pop();
 }
        private void RenderPrefabPreviewRows()
        {
            for (int prefabIndex = 0; prefabIndex < _filteredPrefabs.Count; ++prefabIndex)
            {
                // Start a new row?
                if (prefabIndex % ViewData.NumberOfPrefabsPerRow == 0)
                {
                    if (prefabIndex != 0)
                    {
                        EditorGUILayout.EndHorizontal();
                    }
                    EditorGUILayout.BeginHorizontal();
                }

                // Render the prefab entry
                Prefab prefab = _filteredPrefabs[prefabIndex];
                var    previewButtonRenderData = new PrefabPreviewButtonRenderData();
                previewButtonRenderData.ExtractFromPrefab(prefab, ViewData.PrefabPreviewScale);

                EditorGUILayout.BeginVertical(GUILayout.Width(previewButtonRenderData.ButtonWidth));

                // Render the prefab preview button
                EditorGUIColor.Push(prefab == _prefabCategory.ActivePrefab ? ViewData.ActivePrefabTint : Color.white);
                if (EditorGUILayoutEx.PrefabPreview(prefab, true, previewButtonRenderData))
                {
                    ObjectPlacementSettings placementSettings = ObjectPlacementSettings.Get();
                    if (placementSettings.ObjectPlacementMode == ObjectPlacementMode.DecorPaint &&
                        placementSettings.DecorPaintObjectPlacementSettings.DecorPaintMode == DecorPaintMode.Brush &&
                        DecorPaintObjectPlacementBrushDatabase.Get().ActiveBrush != null && Event.current.button == (int)MouseButton.Right)
                    {
                        UndoEx.RecordForToolAction(DecorPaintObjectPlacementBrushDatabase.Get().ActiveBrush);
                        DecorPaintObjectPlacementBrushElement brushElement = DecorPaintObjectPlacementBrushDatabase.Get().ActiveBrush.CreateNewElement();
                        brushElement.Prefab = prefab;
                        Octave3DWorldBuilder.ActiveInstance.RepaintAllEditorWindows();
                        Octave3DWorldBuilder.ActiveInstance.Inspector.Repaint();
                    }
                    else
                    if (Octave3DWorldBuilder.ActiveInstance.Inspector.ActiveInspectorGUIIdentifier == InspectorGUIIdentifier.ObjectSelection &&
                        AllShortcutCombos.Instance.ReplacePrefabsForSelectedObjects.IsActive())
                    {
                        ObjectSelection.Get().ReplaceSelectedObjectsWithPrefab(prefab);
                    }
                    else
                    {
                        UndoEx.RecordForToolAction(_prefabCategory);
                        _prefabCategory.SetActivePrefab(prefab);
                    }
                }
                EditorGUIColor.Pop();

                // Render the prefab name labels if necessary
                if (ViewData.ShowPrefabNames)
                {
                    Rect previewRectangle = GUILayoutUtility.GetLastRect();
                    EditorGUILayoutEx.LabelInMiddleOfControlRect(previewRectangle, prefab.Name, previewButtonRenderData.ButtonHeight, GetStyleForPrefabNameLabel());
                }

                // Render the remove prefab button
                if (GUILayout.Button(GetRemovePrefabButtonContent()))
                {
                    UndoEx.RecordForToolAction(_prefabCategory);
                    _prefabCategory.RemoveAndDestroyPrefab(prefab);
                    Octave3DWorldBuilder.ActiveInstance.Inspector.Repaint();
                }

                EditorGUILayout.EndVertical();
            }

            // End the last row (if any)
            if (_filteredPrefabs.Count != 0)
            {
                EditorGUILayout.EndHorizontal();
            }
        }
コード例 #5
0
 public static void InformativeLabel(string labelText, Color labelColor, bool requireWordWrap = true)
 {
     EditorGUIColor.Push(labelColor);
     EditorGUILayout.LabelField(labelText, EditorGUIStylesFactory.CreateInformativeLabelStyle(labelColor, requireWordWrap));
     EditorGUIColor.Pop();
 }
コード例 #6
0
        protected override void RenderContent()
        {
            RenderNameChangeField();
            RenderRadiusField();
            RenderMaxNumberOfObjectsField();
            RenderDistanceBetweenObjectsField();
            RenderIgnoreObjectsOutsideOfPaintSurfaceToggle();
            RenderDestinationCategoryForElementPrefabsSelectionPopup();

            EditorGUILayout.Separator();
            if (!_brush.IsEmpty)
            {
                Octave3DWorldBuilder.ActiveInstance.ShowGUIHint("Left click on an element's preview to change its parameters. Right click to remove the element from the brush. SHIFT + Right click to toggle the element on/off.");
            }
            Data.ElementsScrollPos = EditorGUILayout.BeginScrollView(Data.ElementsScrollPos, "Box", GUILayout.Height(Data.ElementsScrollViewHeight));
            if (_brush.IsEmpty)
            {
                EditorGUILayout.HelpBox("There are no brush elements available. You can drag and drop prefabs onto this area or " +
                                        "right click on prefabs inside the active category to create new elements. All brush elements will " +
                                        "be shown with a preview inside this area.", UnityEditor.MessageType.None);
            }
            else
            {
                List <DecorPaintObjectPlacementBrushElement> allBrushElements = _brush.GetAllBrushElements();
                for (int brushElemIndex = 0; brushElemIndex < allBrushElements.Count; ++brushElemIndex)
                {
                    if (brushElemIndex % Data.NumElementsPerRow == 0)
                    {
                        if (brushElemIndex != 0)
                        {
                            EditorGUILayout.EndHorizontal();
                        }
                        EditorGUILayout.BeginHorizontal();
                    }

                    DecorPaintObjectPlacementBrushElement brushElement = allBrushElements[brushElemIndex];
                    var previewButtonRenderData = new PrefabPreviewButtonRenderData();
                    previewButtonRenderData.ExtractFromPrefab(brushElement.Prefab, Data.ElementPreviewScale);

                    Color previewTint = brushElement != _brush.ActiveElement ? Color.white : Data.ActiveElementTintColor;
                    if (_brush.ActiveElement != brushElement && !brushElement.IsEnabled)
                    {
                        previewTint = Data.DisabledElementTintColor;
                    }

                    EditorGUILayout.BeginVertical(GUILayout.Width(previewButtonRenderData.ButtonWidth));
                    EditorGUIColor.Push(previewTint);
                    if (EditorGUILayoutEx.PrefabPreview(brushElement.Prefab, true, previewButtonRenderData))
                    {
                        if (Event.current.button == (int)MouseButton.Left)
                        {
                            if (brushElement != _brush.ActiveElement)
                            {
                                UndoEx.RecordForToolAction(_brush);
                                _brush.SetActiveElement(brushElement);
                            }
                        }
                        else
                        if (Event.current.button == (int)MouseButton.Right)
                        {
                            if (!Event.current.shift)
                            {
                                UndoEx.RecordForToolAction(_brush);
                                _brush.RemoveAndDestroyElement(brushElement);
                            }
                            else
                            {
                                UndoEx.RecordForToolAction(brushElement);
                                brushElement.IsEnabled = !brushElement.IsEnabled;
                            }
                        }
                    }
                    EditorGUIColor.Pop();
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndScrollView();
            Rect prefabDropRect = GUILayoutUtility.GetLastRect();

            EditorGUILayout.BeginHorizontal();
            var content = new GUIContent();

            content.text    = "Load active category";
            content.tooltip = "Loads all the prefabs from the active category inside the active brush. Note: Prefabs which already exist in the brush, will be ignored.";
            if (GUILayout.Button(content, GUILayout.Width(130.0f)))
            {
                UndoEx.RecordForToolAction(_brush);
                _brush.LoadAllPrefabsInActiveCategory();
            }
            RenderRemoveAllElementsButton();

            content.text    = "Look and feel...";
            content.tooltip = "Opens up a new window which allows you to control the look and feel of the brush elements view.";
            if (GUILayout.Button(content, GUILayout.Width(110.0f)))
            {
                Octave3DWorldBuilder.ActiveInstance.EditorWindowPool.DecorPaintBrushViewLookAndFeelWindow.ViewData = Data;
                Octave3DWorldBuilder.ActiveInstance.EditorWindowPool.DecorPaintBrushViewLookAndFeelWindow.ShowOctave3DWindow();
            }
            EditorGUILayout.EndHorizontal();

            if (_brush.ActiveElement != null)
            {
                EditorGUILayout.Separator();
                _brush.ActiveElement.View.Render();
            }

            PrefabsToDecorPaintBrushEventHandler.Get().DropDest         = PrefabsToDecorPaintBrushEventHandler.DropDestination.Brush;
            PrefabsToDecorPaintBrushEventHandler.Get().DestinationBrush = _brush;
            PrefabsToDecorPaintBrushEventHandler.Get().Handle(Event.current, prefabDropRect);
        }