コード例 #1
0
        void DrawDefineSymbolsSymbolsPreset(float width)
        {
            QUI.BeginVertical(width);
            {
                QUI.GhostTitle("SYMBOLS PRESET", QColors.Color.Green, width);
                QUI.Space(SPACE_4);
                QUI.BeginHorizontal(width);
                {
                    QUI.Space(SPACE_8);
                    if (QUI.GhostButton("<<<   Copy to Build Target Group", QColors.Color.Green, width - SPACE_8, 24))
                    {
                        List <string> tempList = presetSymbols;
                        tempList = QUtils.CleanList(tempList);
                        presetSymbols.Clear();
                        presetSymbols.AddRange(tempList);
                        symbols.Clear();
                        symbols.AddRange(presetSymbols);
                        QUtils.SetScriptingDefineSymbolsForGroup(selectedBuildTargetGroup, symbols);
                        if (presetSymbols.Count == 0)
                        {
                            presetSymbols.Add("");
                        }
                    }
                    QUI.FlexibleSpace();
                }
                QUI.EndHorizontal();
                QUI.Space(SPACE_4);
                if (defineSymbolsNewPreset.value) //NEW PRESET
                {
                    QUI.BeginHorizontal(width);
                    {
                        QUI.Space(SPACE_8);
                        QUI.Label("Enter a new preset name...", Style.Text.Small, width - SPACE_8);
                    }
                    QUI.EndHorizontal();

                    QUI.Space(-SPACE_4);

                    QUI.BeginHorizontal(width);
                    {
                        QUI.Space(SPACE_8);
                        GUI.SetNextControlName("newPresetName");
                        newPresetName = QUI.TextField(newPresetName, EditorGUIUtility.isProSkin ? QColors.Green.Color : QColors.GreenLight.Color, (width - SPACE_8 - 16 - 2 - 16) * defineSymbolsNewPreset.faded);

                        //if the user hits Enter while either the key or value fields were being edited
                        bool keyboardReturnPressed = Event.current.isKey &&
                                                     Event.current.keyCode == KeyCode.Return &&
                                                     Event.current.type == EventType.KeyUp &&
                                                     (GUI.GetNameOfFocusedControl() == "newPresetName");

                        QUI.Space(-2);
                        if (QUI.ButtonOk() || keyboardReturnPressed)
                        {
                            newPresetName = newPresetName.Trim();
                            if (newPresetName.Equals(DEFAULT_PRESET_NAME))
                            {
                                QUI.DisplayDialog("Enter a new preset name", "You are trying to save a preset with the defaut preset name '" + DEFAULT_PRESET_NAME + "'. Please enter another preset name.", "Ok");
                            }
                            else if (string.IsNullOrEmpty(newPresetName))
                            {
                                QUI.DisplayDialog("Enter a new preset name", "You are trying to save a preset with no name. Please enter a name.", "Ok");
                            }
                            else if (Q.GetResource <DefineSymbols.DefineSymbolsPreset>(EZT.RESOURCES_PATH_DEFINE_SYMBOLS_PRESETS, newPresetName) != null)
                            {
                                if (QUI.DisplayDialog("Overwrite preset?", "There is a preset with the same name '" + newPresetName + "' in the presets list. Are you sure you want to overwrite it?", "Overwrite", "Cancel"))
                                {
                                    AssetDatabase.MoveAssetToTrash(EZT.RELATIVE_PATH_DEFINE_SYMBOLS_PRESETS + newPresetName + ".asset");
                                    SavePreset(presetSymbols, newPresetName);
                                    selectedPresetName = newPresetName;
                                    RefreshPresetNames();
                                    defineSymbolsNewPreset.target = false;
                                    newPresetName = "";
                                }
                            }
                            else
                            {
                                SavePreset(presetSymbols, newPresetName);
                                selectedPresetName = newPresetName;
                                RefreshPresetNames();
                                defineSymbolsNewPreset.target = false;
                                newPresetName = "";
                            }
                        }
                        QUI.Space(2);

                        //if the user hits Escape while either the key or value fields were being edited
                        bool keyboardEscapePressed = Event.current.isKey &&
                                                     Event.current.keyCode == KeyCode.Escape &&
                                                     Event.current.type == EventType.KeyUp &&
                                                     (GUI.GetNameOfFocusedControl() == "newPresetName");

                        if (QUI.ButtonCancel() || keyboardEscapePressed)
                        {
                            defineSymbolsNewPreset.target = false;
                            newPresetName = "";
                        }
                        QUI.FlexibleSpace();
                    }
                    QUI.EndHorizontal();
                    QUI.Space(5);
                }
                else //NORMAL VIEW
                {
                    QUI.BeginHorizontal(width);
                    {
                        QUI.Space(SPACE_8);
                        QUI.BeginChangeCheck();
                        QUI.SetGUIBackgroundColor(EditorGUIUtility.isProSkin ? QColors.Green.Color : QColors.GreenLight.Color);
                        selectedPresetIndex = EditorGUILayout.Popup(selectedPresetIndex, presets, GUILayout.Width(width - SPACE_8));
                        QUI.ResetColors();
                        if (QUI.EndChangeCheck())
                        {
                            Undo.RecordObject(this, "Select Preset");
                            selectedPresetName = presets[selectedPresetIndex];
                        }
                        QUI.FlexibleSpace();
                    }
                    QUI.EndHorizontal();

                    QUI.Space(SPACE_2);

                    if (loadedPresetName.Equals(selectedPresetName) || selectedPresetName.Equals(DEFAULT_PRESET_NAME))
                    {
                        QUI.BeginHorizontal(width);
                        {
                            QUI.Space(SPACE_8);
                            if (selectedPresetName.Equals(DEFAULT_PRESET_NAME))
                            {
                                if (QUI.GhostButton("Create a New Preset with current symbols", QColors.Color.Green, width - SPACE_8))
                                {
                                    defineSymbolsNewPreset.target = true;
                                    newPresetName = "";
                                }
                            }
                            else
                            {
                                if (QUI.GhostButton("NEW", QColors.Color.Green, ((width - SPACE_8) / 4) - SPACE_2))
                                {
                                    defineSymbolsNewPreset.target = true;
                                    newPresetName = "";
                                }
                                QUI.Space(SPACE_2);
                                if (QUI.GhostButton("RELOAD", QColors.Color.Green, ((width - SPACE_8) / 4) - SPACE_2))
                                {
                                    LoadPreset(selectedPresetName);
                                }
                                QUI.Space(SPACE_2);
                                if (QUI.GhostButton("SAVE", QColors.Color.Green, ((width - SPACE_8) / 4) - SPACE_2))
                                {
                                    SavePreset(presetSymbols, selectedPresetName);
                                }
                                QUI.Space(SPACE_2);
                                if (QUI.GhostButton("DELETE", QColors.Color.Red, ((width - SPACE_8) / 4) - SPACE_2))
                                {
                                    if (QUI.DisplayDialog("Delete preset?", "Are you sure you want to delete the '" + selectedPresetName + "' preset?", "Yes", "No"))
                                    {
                                        DeletePreset(selectedPresetName);
                                    }
                                }
                            }
                            QUI.FlexibleSpace();
                        }
                        QUI.EndHorizontal();
                    }
                    else
                    {
                        QUI.BeginHorizontal(width);
                        {
                            QUI.Space(SPACE_8);
                            if (QUI.GhostButton("Load Preset", QColors.Color.Green, width - SPACE_8))
                            {
                                LoadPreset(selectedPresetName);
                            }
                            QUI.FlexibleSpace();
                        }
                        QUI.EndHorizontal();
                    }
                }

                QUI.Space(-SPACE_8 - SPACE_4);
                DrawSelectedPresetsList(width);
            }
            QUI.EndVertical();
        }
コード例 #2
0
        private void DrawLocations()
        {
            QUI.BeginHorizontal(WIDTH_420);
            {
                QUI.SetGUIBackgroundColor(AccentColorBlue);
                QUI.BeginChangeCheck();
                QUI.Toggle(useSpawnerAsSpawnLocation);
                if (QUI.EndChangeCheck())
                {
                    HandleUtility.Repaint();
                    SceneView.RepaintAll();
                    Repaint();
                }
                QUI.ResetColors();
                if (useSpawnerAsSpawnLocation.boolValue && poolySpawner.spawnPositions != null && poolySpawner.spawnPositions.Count > 0)
                {
                    spawnPositions.ClearArray();
                    spawnPositions.InsertArrayElementAtIndex(0);
                    spawnPositions.GetArrayElementAtIndex(0).FindPropertyRelative("spawnPosition").vector3Value = new Vector3(0, 1, 0);

                    serializedObject.ApplyModifiedProperties();
                    HandleUtility.Repaint();
                    SceneView.RepaintAll();
                    Repaint();
                }
                if (useSpawnerAsSpawnLocation.boolValue && poolySpawner.spawnPoints != null && poolySpawner.spawnPoints.Count > 0)
                {
                    spawnPoints.ClearArray();
                    spawnPoints.InsertArrayElementAtIndex(0);

                    serializedObject.ApplyModifiedProperties();
                    HandleUtility.Repaint();
                    SceneView.RepaintAll();
                    Repaint();
                }
                QUI.Label("使用预制体的坐标作为产生点", Style.Text.Normal, 200);
            }
            QUI.EndHorizontal();
            if (useSpawnerAsSpawnLocation.boolValue)
            {
                return;
            }
            else
            {
                QUI.Space(-SPACE_4);
            }
            animBoolShowSpawnLocationsOptions.target = !useSpawnerAsSpawnLocation.boolValue;
            if (QUI.BeginFadeGroup(animBoolShowSpawnLocationsOptions.faded))
            {
                QUI.Space(SPACE_8);
                QUI.BeginVertical();
                {
                    QUI.Space(SPACE_4);
                    QUI.Box(QStyles.GetBackgroundStyle(Style.BackgroundType.Low, QColors.Color.Blue), WIDTH_420, 20);
                    QUI.Space(-20);
                    QUI.BeginHorizontal(WIDTH_420);
                    {
                        QUI.Space(SPACE_4);
                        QUI.Label("SPAWN AT", Style.Text.Normal, 60);
                        QUI.SetGUIBackgroundColor(AccentColorBlue);
                        QUI.BeginChangeCheck();
                        {
                            QUI.Popup(spawnAt, 70);
                        }
                        if (QUI.EndChangeCheck())
                        {
                            Undo.RecordObject(poolySpawner, "SpawnAt Change");

                            spawnPositions.ClearArray();
                            spawnPositions.InsertArrayElementAtIndex(0);
                            spawnPositions.GetArrayElementAtIndex(0).FindPropertyRelative("spawnPosition").vector3Value = new Vector3(0, 1, 0);

                            spawnPoints.ClearArray();
                            spawnPoints.InsertArrayElementAtIndex(0);
                            serializedObject.ApplyModifiedProperties();
                        }
                        QUI.ResetColors();
                        QUI.FlexibleSpace();
                        if ((poolySpawner.spawnPositions != null && poolySpawner.spawnPositions.Count > 1 && poolySpawner.spawnAt == PoolySpawner.SpawnAt.Position) ||
                            (poolySpawner.spawnPoints != null && poolySpawner.spawnPoints.Count > 1 && poolySpawner.spawnAt == PoolySpawner.SpawnAt.Transform))
                        {
                            QUI.Label("Spawn Type", Style.Text.Normal, 68);
                            QUI.SetGUIBackgroundColor(AccentColorBlue);
                            QUI.Popup(locationSpawnType, 80, SpawnTypes);
                            QUI.ResetColors();
                        }
                        QUI.Space(SPACE_8);
                    }
                    QUI.EndHorizontal();
                    QUI.Space(SPACE_4);
                    switch (poolySpawner.spawnAt)
                    {
                    case PoolySpawner.SpawnAt.Position:
                        if (poolySpawner.spawnPositions == null || poolySpawner.spawnPositions.Count == 0)
                        {
                            poolySpawner.spawnPositions = new List <PoolySpawner.SpawnPosition> {
                                new PoolySpawner.SpawnPosition(new Vector3(0, 1, 0))
                            };
                        }
                        if (poolySpawner.spawnPositions.Count == 1 && poolySpawner.locationSpawnType == PoolySpawner.SpawnType.Random)
                        {
                            poolySpawner.locationSpawnType = PoolySpawner.SpawnType.Sequential;
                        }
                        for (int i = 0; i < poolySpawner.spawnPositions.Count; i++)
                        {
                            QUI.BeginHorizontal(WIDTH_420);
                            {
                                tempContent     = new GUIContent(i.ToString());
                                tempContentSize = QStyles.CalcSize(tempContent, Style.Text.Small);
                                QUI.Label(tempContent.text, Style.Text.Small, tempContentSize.x);
                                QUI.BeginChangeCheck();
                                Vector3 spawnPosition = poolySpawner.spawnPositions[i].spawnPosition;
                                QUI.SetGUIBackgroundColor(AccentColorBlue);
                                spawnPosition = QUI.Vector3(spawnPosition, (WIDTH_420 - SPACE_2 - tempContentSize.x - SPACE_8 - SPACE_16 - SPACE_4) - 240 * animBoolRandomSpawnLocation.faded);
                                QUI.ResetColors();
                                if (QUI.EndChangeCheck())
                                {
                                    Undo.RecordObject(poolySpawner, "Changed Spawn Position " + i);
                                    poolySpawner.spawnPositions[i].spawnPosition = spawnPosition;
                                    QUI.SetDirty(poolySpawner);
                                }
                                if (QUI.ButtonMinus())
                                {
                                    if (poolySpawner.spawnPositions.Count > 1)
                                    {
                                        Undo.RecordObject(poolySpawner, "Removed Spawn Position " + i);
                                        poolySpawner.spawnPositions.RemoveAt(i);
                                    }
                                    else if (poolySpawner.spawnPositions == null || poolySpawner.spawnPositions[0].spawnPosition != new Vector3(poolySpawner.transform.position.x, poolySpawner.transform.position.y + 1, poolySpawner.transform.position.z))
                                    {
                                        Undo.RecordObject(poolySpawner, "Reset Spawn Position");
                                        poolySpawner.spawnPositions = new List <PoolySpawner.SpawnPosition> {
                                            new PoolySpawner.SpawnPosition(new Vector3(poolySpawner.transform.position.x, poolySpawner.transform.position.y + 1, poolySpawner.transform.position.z))
                                        };
                                    }
                                    QUI.SetDirty(poolySpawner);
                                    QUI.ExitGUI();
                                }
                                animBoolRandomSpawnLocation.target = locationSpawnType.enumValueIndex == (int)PoolySpawner.SpawnType.Random;
                                if (poolySpawner.spawnPositions != null && poolySpawner.spawnPositions.Count > 1 && locationSpawnType.enumValueIndex == (int)PoolySpawner.SpawnType.Random)
                                {
                                    QUI.Space(SPACE_2);
                                    QUI.Label("weight", Style.Text.Small, 40 * animBoolRandomSpawnLocation.faded);
                                    QUI.Space(-SPACE_8);
                                    QUI.BeginChangeCheck();
                                    int spawnPositionWeight = poolySpawner.spawnPositions[i].weight;
                                    QUI.SetGUIBackgroundColor(AccentColorBlue);
                                    spawnPositionWeight = EditorGUILayout.IntSlider(spawnPositionWeight, 0, 100);
                                    QUI.ResetColors();
                                    if (QUI.EndChangeCheck())
                                    {
                                        Undo.RecordObject(poolySpawner, "Changed Weight Of Spawn Position " + i);
                                        poolySpawner.spawnPositions[i].weight = spawnPositionWeight;
                                    }
                                }
                                QUI.FlexibleSpace();
                                QUI.Space(SPACE_8);
                            }
                            QUI.EndHorizontal();
                            QUI.Space(1);
                        }
                        QUI.Space(SPACE_2);
                        QUI.BeginHorizontal(WIDTH_420);
                        {
                            QUI.FlexibleSpace();
                            if (QUI.ButtonPlus())
                            {
                                Undo.RecordObject(poolySpawner, "Added Spawn Position");
                                poolySpawner.spawnPositions.Add(new PoolySpawner.SpawnPosition(new Vector3(poolySpawner.transform.position.x, poolySpawner.transform.position.y + 1, poolySpawner.transform.position.z)));
                                QUI.SetDirty(poolySpawner);
                                QUI.ExitGUI();
                            }
                            QUI.Space(3 + 240 * animBoolRandomSpawnLocation.faded);
                        }
                        QUI.EndHorizontal();
                        break;

                    case PoolySpawner.SpawnAt.Transform:
                        if (poolySpawner.spawnPoints == null || poolySpawner.spawnPoints.Count == 0)
                        {
                            poolySpawner.spawnPoints = new List <PoolySpawner.SpawnPoint> {
                                new PoolySpawner.SpawnPoint(null)
                            };
                        }
                        if (poolySpawner.spawnPoints.Count == 1 && poolySpawner.locationSpawnType == PoolySpawner.SpawnType.Random)
                        {
                            poolySpawner.locationSpawnType = PoolySpawner.SpawnType.Sequential;
                        }
                        infoMessage["NoSpawnPoint"].show.target = !poolySpawner.HasSpawnPoints();
                        // 画框框提示
                        DrawInfoMessage("NoSpawnPoint", WIDTH_420 - 20);
                        for (int i = 0; i < poolySpawner.spawnPoints.Count; i++)
                        {
                            QUI.BeginHorizontal(WIDTH_420);
                            {
                                tempContent     = new GUIContent(i.ToString());
                                tempContentSize = QStyles.CalcSize(tempContent, Style.Text.Small);
                                QUI.Label(tempContent.text, Style.Text.Small, tempContentSize.x);
                                QUI.BeginChangeCheck();
                                Transform spawnPoint = poolySpawner.spawnPoints[i].spawnPoint;
                                QUI.SetGUIBackgroundColor(AccentColorBlue);
                                spawnPoint = (Transform)QUI.ObjectField(spawnPoint, typeof(Transform), true, (WIDTH_420 - SPACE_2 - tempContentSize.x - SPACE_8 - SPACE_16 - SPACE_4) - 240 * animBoolRandomSpawnLocation.faded);
                                QUI.ResetColors();
                                if (QUI.IsPersistent(spawnPoint))
                                {
                                    spawnPoint = poolySpawner.spawnPoints[i].spawnPoint;
                                }
                                if (QUI.EndChangeCheck())
                                {
                                    Undo.RecordObject(poolySpawner, "Changed Reference For Spawn Point Slot " + i);
                                    poolySpawner.spawnPoints[i].spawnPoint = spawnPoint;
                                    QUI.SetDirty(poolySpawner);
                                }
                                QUI.BeginVertical(16);
                                {
                                    QUI.Space(SPACE_2);
                                    if (QUI.ButtonMinus())
                                    {
                                        if (poolySpawner.spawnPoints.Count > 1)
                                        {
                                            Undo.RecordObject(poolySpawner, "Removed Spawn Point Slot " + i);
                                            poolySpawner.spawnPoints.RemoveAt(i);
                                        }
                                        else if (poolySpawner.spawnPoints == null || poolySpawner.spawnPoints[0].spawnPoint != null)
                                        {
                                            Undo.RecordObject(poolySpawner, "Reset Spawn Point Slot");
                                            poolySpawner.spawnPoints = new List <PoolySpawner.SpawnPoint> {
                                                new PoolySpawner.SpawnPoint(null)
                                            };
                                        }
                                        QUI.SetDirty(poolySpawner);
                                        QUI.ExitGUI();
                                    }
                                }
                                QUI.EndVertical();
                                animBoolRandomSpawnLocation.target = locationSpawnType.enumValueIndex == (int)PoolySpawner.SpawnType.Random;
                                if (poolySpawner.spawnPoints != null && poolySpawner.spawnPoints.Count > 1 && locationSpawnType.enumValueIndex == (int)PoolySpawner.SpawnType.Random)
                                {
                                    QUI.Space(SPACE_2);
                                    QUI.Label("weight", Style.Text.Small, 40);
                                    QUI.Space(-SPACE_8);
                                    QUI.BeginChangeCheck();
                                    int spawnPointWeight = poolySpawner.spawnPoints[i].weight;
                                    QUI.SetGUIBackgroundColor(AccentColorBlue);
                                    spawnPointWeight = EditorGUILayout.IntSlider(spawnPointWeight, 0, 100);
                                    QUI.ResetColors();
                                    if (QUI.EndChangeCheck())
                                    {
                                        Undo.RecordObject(poolySpawner, "Changed Weight Of Spawn Point " + i);
                                        poolySpawner.spawnPoints[i].weight = spawnPointWeight;
                                    }
                                }
                                QUI.FlexibleSpace();
                                QUI.Space(SPACE_8);
                            }
                            QUI.EndHorizontal();
                            QUI.Space(1);
                        }
                        QUI.Space(SPACE_2);
                        QUI.BeginHorizontal(WIDTH_420);
                        {
                            QUI.FlexibleSpace();
                            if (QUI.ButtonPlus())
                            {
                                Undo.RecordObject(poolySpawner, "Added Spawn Point Slot");
                                poolySpawner.spawnPoints.Add(new PoolySpawner.SpawnPoint(null));
                                QUI.SetDirty(poolySpawner);
                                QUI.ExitGUI();
                            }
                            QUI.Space(3 + 240 * animBoolRandomSpawnLocation.faded);
                        }
                        QUI.EndHorizontal();
                        break;
                    }
                }
                QUI.EndVertical();
            }
            QUI.EndFadeGroup();
        }