Exemplo n.º 1
0
        private void DrawAdvancedSettings()
        {
            EditorGUILayout.EditorToolbar();
            showAdvancedSettings = EditorGUILayout.BeginFoldoutHeaderGroup(showAdvancedSettings, "Advanced",
                                                                           JuicyStyles.HeaderFoldout);

            if (showAdvancedSettings)
            {
                EditorGUILayout.PropertyField(CacheProperty("playOnEnable"));

                using (new EditorGUI.DisabledScope(!Application.isPlaying))
                    using (new EditorGUILayout.HorizontalScope()) {
                        if (GUILayout.Button("Play"))
                        {
                            juicyFeedbackList.Play();
                        }

                        /*if (GUILayout.Button("Pause")) {
                         *  juicyFeedbackList.Pause();
                         * }*/

                        if (GUILayout.Button("Stop"))
                        {
                            juicyFeedbackList.Stop();
                        }
                    }
            }
            EditorGUILayout.EndFoldoutHeaderGroup();
        }
Exemplo n.º 2
0
    protected override void OnGUI()
    {
        base.OnGUI();

        if (GUILayout.Button("查看工具代码"))
        {
            SEditorUtility.GoToPath(toolScriptPath);
        }
        EditorGUILayout.LabelField("单个显示");
        EditorGUILayout.EditorToolbar(CreateInstance <CustomTool>());


        EditorGUILayout.LabelField("列表显示");
        var tlist = new List <EditorTool>();

        tlist.Add(CreateInstance <CustomTool>());
        tlist.Add(CreateInstance <LikeTool>());
        EditorGUILayout.EditorToolbar <EditorTool>(tlist);

        //试了多次也没明白 EditorToolbarForTarget 的用法
        //var go = GameObject.Find("Cube");
        //EditorGUILayout.EditorToolbarForTarget(content, go);

        EditorGUILayout.LabelField("工具栏工具位置");
        var Rect = EditorGUILayout.GetControlRect();

        Rect.height = texture.height;
        Rect.width  = texture.width;
        GUI.DrawTexture(Rect, texture);
    }
Exemplo n.º 3
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            DrawDefaultInspector();
            serializedObject.ApplyModifiedProperties();

            GUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Paint");
            EditorGUILayout.EditorToolbar(TesseraTileEditorToolBase.tile3dEditorTools);
            GUILayout.EndHorizontal();
        }
        void OnGUI()
        {
            GUILayout.Label("View", EditorStyles.boldLabel);

            TesseraTilePaintingState.showBackface = EditorGUILayout.Toggle(new GUIContent("Show Backfaces", "Z to toggle"), TesseraTilePaintingState.showBackface);

            TesseraTilePaintingState.opacity = EditorGUILayout.Slider("Opacity", TesseraTilePaintingState.opacity, 0, 1);

            TesseraTilePaintingState.showAll = EditorGUILayout.Toggle(new GUIContent("Show All"), TesseraTilePaintingState.showAll);

            GUILayout.Label("Painting", EditorStyles.boldLabel);

            // TODO: See C:\Program Files\Unity\Hub\Editor\2019.2.3f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.2d.tilemap\Editor\EditorTools
            // For some further stuff to do here

            GUILayout.Label("Paint Mode");

            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            EditorGUILayout.EditorToolbar(TesseraTileEditorToolBase.tile3dEditorTools);

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.Label("Paint Color");

            var r = EditorGUILayout.BeginVertical();

            r.width = position.width;

            var boxStyle = GUI.skin.box;
            var tileSize = 20;

            var boxRect   = boxStyle.margin.Remove(r);
            var innerRect = boxStyle.padding.Remove(boxRect);

            // Get palette
            TesseraPalette palette = null;

            if (Selection.activeGameObject != null)
            {
                if (Selection.activeGameObject.GetComponent <TesseraTile>() is TesseraTile t)
                {
                    palette = t.palette;
                }
            }
            if (palette == null)
            {
                palette = TesseraPalette.defaultPalette;
            }

            var tilesPerRow = (int)(innerRect.width / tileSize);

            if (tilesPerRow > 0)
            {
                innerRect.height = (palette.entryCount + tilesPerRow - 1) / tilesPerRow * tileSize;
                boxRect          = boxStyle.padding.Add(innerRect);

                GUI.Box(boxRect, "");

                for (var i = 0; i < palette.entryCount; i++)
                {
                    var x        = innerRect.x + (i % tilesPerRow) * tileSize;
                    var y        = innerRect.y + (i / tilesPerRow) * tileSize;
                    var tileRect = new Rect(x, y, tileSize, tileSize);

                    var selected = TesseraTilePaintingState.paintIndex == i;
                    if (Event.current.type == EventType.Repaint)
                    {
                        TextureUtil.DrawBox(tileRect, selected, palette, i);
                    }
                }

                if (Event.current.type == EventType.MouseDown)
                {
                    var mousePosition = Event.current.mousePosition;
                    if (innerRect.Contains(mousePosition))
                    {
                        var x = (int)(mousePosition.x - innerRect.x) / tileSize;
                        var y = (int)(mousePosition.y - innerRect.y) / tileSize;
                        var i = x + y * tilesPerRow;
                        TesseraTilePaintingState.paintIndex = i;
                        Repaint();
                    }
                }

                // TODO: Handle tooltip
            }
            EditorGUILayout.EndVertical();

            GUILayout.Space(boxStyle.margin.Add(boxRect).height);

            TesseraTileEditorToolBase.CheckKeyPresses();
        }
Exemplo n.º 5
0
    public void EditorGUILayoutExamples()
    {
        EditorGUILayout.LabelField("Hello World!");

        Rect rect = EditorGUILayout.GetControlRect(false, 50);

        GUI.Button(rect, GUIContent.none);


        gradient = EditorGUILayout.GradientField("Gradient", gradient);
        //EditorGUILayout.HelpBox("Hello, World !", MessageType.Info);
        //EditorGUILayout.HelpBox("Hello, World !", MessageType.Error);
        EditorGUILayout.HelpBox("Hello, World !", MessageType.Warning);
        //EditorGUILayout.HelpBox("Hello, World !", MessageType.None);
        EditorGUILayout.SelectableLabel("This is a selectable label");

        EditorGUILayout.DropdownButton(GUIContent.none, FocusType.Keyboard);

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal("Toolbar", GUILayout.ExpandWidth(true));
        {
            if (GUILayout.Button("Clear", "ToolbarButton", GUILayout.Width(45f)))
            {
                Debug.Log("You click Clear button");
            }
            // Create space between Clear and Collapse button.
            GUILayout.Space(5f);
            // Create toggles button.
            collapsed   = GUILayout.Toggle(collapsed, "Collapse", "ToolbarButton");
            clearOnPlay = GUILayout.Toggle(clearOnPlay, "Clear on Play", "ToolbarButton");
            // Push content to be what they should be. (ex. width)
            GUILayout.FlexibleSpace();
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.EditorToolbar(vertexTool);

        bounds      = EditorGUILayout.BoundsField("Bounds", bounds);
        doubleValue = EditorGUILayout.DelayedDoubleField("Delayed Double", doubleValue);

        BuildTargetGroup buildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();

        {
            EditorGUI.indentLevel++;
            EditorGUILayout.LabelField($"BuildTarget:{buildTargetGroup}");
            EditorGUI.indentLevel--;
        }
        EditorGUILayout.EndBuildTargetSelectionGrouping();


        using (var v = new EditorGUILayout.VerticalScope("button"))
        {
            Rect r = new Rect(v.rect);
            r.height = r.height / 2;
            if (GUI.Button(r, GUIContent.none))
            {
                Debug.Log("Go here");
            }
            GUILayout.Label("I'm inside the button");
            GUILayout.Label("So am I");
            GUILayout.Label($"{v.rect.width} x {v.rect.height}");
        }

        //
        m_ShowExtraFields.target = EditorGUILayout.ToggleLeft("Show extra fields", m_ShowExtraFields.target);

        //Extra block that can be toggled on and off.
        using (var group = new EditorGUILayout.FadeGroupScope(m_ShowExtraFields.faded))
        {
            if (group.visible)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PrefixLabel("Color");
                m_Color = EditorGUILayout.ColorField(m_Color);
                EditorGUILayout.PrefixLabel("Text");
                m_String = EditorGUILayout.TextField(m_String);
                EditorGUILayout.PrefixLabel("Number");
                m_Number = EditorGUILayout.IntSlider(m_Number, 0, 10);
                EditorGUI.indentLevel--;
            }
        }


        using (var h = new EditorGUILayout.HorizontalScope())
        {
            using (var scrollView = new EditorGUILayout.ScrollViewScope(scrollPos, GUILayout.Width(100), GUILayout.Height(100)))
            {
                scrollPos = scrollView.scrollPosition;
                GUILayout.Label(t);
            }
            if (GUILayout.Button("Add More Text", GUILayout.Width(100), GUILayout.Height(100)))
            {
                t += " \nAnd this is more text!";
            }
        }
        if (GUILayout.Button("Clear"))
        {
            t = "";
        }

        using (var posGroup = new EditorGUILayout.ToggleGroupScope("Align position", posGroupEnabled))
        {
            EditorGUI.indentLevel++;
            posGroupEnabled = posGroup.enabled;
            pos[0]          = EditorGUILayout.Toggle("x", pos[0]);
            pos[1]          = EditorGUILayout.Toggle("y", pos[1]);
            pos[2]          = EditorGUILayout.Toggle("z", pos[2]);
            EditorGUI.indentLevel--;
        }
    }