Example #1
0
 void DrawNewsArticle(List <NewsArticleData> articles, int index, Object targetObject, bool showDeleteButton, float width)
 {
     QLabel.text  = articles[index].title;
     QLabel.style = Style.Text.Subtitle;
     QUI.Box(QStyles.GetBackgroundStyle(Style.BackgroundType.Low, QColors.Color.Gray), width, 20);
     QUI.Space(-20);
     QUI.BeginHorizontal(width);
     {
         QUI.Space(6);
         QUI.Label(QLabel);
         QUI.FlexibleSpace();
         if (showDeleteButton)
         {
             if (QUI.ButtonMinus())
             {
                 if (QUI.DisplayDialog("Delete Article", "Delete the '" + QLabel.text + "' article?", "Ok", "Cancel"))
                 {
                     articles.RemoveAt(index);
                     QUI.SetDirty(targetObject);
                     AssetDatabase.SaveAssets();
                     QUI.ExitGUI();
                 }
             }
         }
         QUI.Space(SPACE_4);
     }
     QUI.EndHorizontal();
     QLabel.text  = articles[index].content;
     QLabel.style = Style.Text.Normal;
     QUI.Space(-8 + (showDeleteButton ? 2 : 0));
     EditorGUILayout.LabelField(articles[index].content, QStyles.GetInfoMessageMessageStyle(Style.InfoMessage.Help), GUILayout.Width(width));
     QUI.Space(SPACE_4);
 }
Example #2
0
 /// <summary>
 /// Draws a list's line.
 /// </summary>
 /// <param name="list">Target list</param>
 /// <param name="index">Line index</param>
 /// <param name="readOnly">Should the line be editable? If FALSE it will draw a Label. If TRUE it will draw a TextField with - and + buttons</param>
 /// <param name="width">Width of the line</param>
 /// <returns></returns>
 string DrawListItem(List <string> list, int index, bool readOnly, float width, float height)
 {
     if (readOnly)
     {
         QUI.Label(list[index], Style.Text.Normal, width, height);
     }
     else
     {
         QUI.BeginHorizontal(width);
         {
             list[index] = EditorGUILayout.TextField(list[index], GUILayout.Width(width - 41), GUILayout.Height(height));
             if (index == 0 && string.IsNullOrEmpty(list[index]))
             {
             }
             else
             {
                 QUI.SetGUIBackgroundColor(QColors.RedLight.Color);
                 if (QUI.ButtonMinus())
                 {
                     list.Remove(list[index]);
                     QUI.ResetColors();
                     return("");
                 }
                 QUI.ResetColors();
                 QUI.Space(1);
                 QUI.SetGUIBackgroundColor(QColors.GreenLight.Color);
                 if (QUI.ButtonPlus())
                 {
                     list.Insert(index, "");
                 }
                 QUI.ResetColors();
             }
         }
         QUI.EndHorizontal();
     }
     return(list[index]);
 }
        void DrawNotificationItems(float width)
        {
            tempFloat = (20 + 2 + 18 * (uiNotificationManager.NotificationItems.Count + 1) + 2) * showUINotifications.faded; //background height
            if (showUINotifications.faded > 0.1f)
            {
                QUI.BeginHorizontal(width);
                {
                    QUI.Space(4 * showUINotifications.faded);
                    QUI.Box(QStyles.GetBackgroundStyle(Style.BackgroundType.Low, uiNotificationManager.NotificationItems.Count > 0 ? QColors.Color.Purple : QColors.Color.Gray), width - 4, tempFloat);
                }
                QUI.EndHorizontal();
                QUI.Space(-tempFloat);
            }

            if (QUI.SlicedBar("UINotifications", uiNotificationManager.NotificationItems.Count > 0 ? QColors.Color.Purple : QColors.Color.Gray, showUINotifications, width, BarHeight))
            {
                showUINotifications.target = !showUINotifications.target;
            }

            QUI.BeginHorizontal(width);
            {
                QUI.Space(8 * showUINotifications.faded);
                if (QUI.BeginFadeGroup(showUINotifications.faded))
                {
                    QUI.BeginVertical(width - 8);
                    {
                        QUI.Space(2);

                        if (uiNotificationManager.NotificationItems.Count == 0)
                        {
                            QUI.BeginHorizontal(width - 8);
                            {
                                QLabel.text  = "No UINotifications referenced... Click [+] to start...";
                                QLabel.style = Style.Text.Help;
                                QUI.BeginVertical(QLabel.x, QUI.SingleLineHeight);
                                {
                                    QUI.Label(QLabel);
                                    QUI.Space(2);
                                }
                                QUI.EndVertical();

                                QUI.FlexibleSpace();

                                QUI.BeginVertical(16, QUI.SingleLineHeight);
                                {
                                    if (QUI.ButtonPlus())
                                    {
                                        NotificationItems.InsertArrayElementAtIndex(NotificationItems.arraySize);
                                    }
                                    QUI.Space(1);
                                }
                                QUI.EndVertical();

                                QUI.Space(4);
                            }
                            QUI.EndHorizontal();
                        }
                        else
                        {
                            QUI.BeginVertical(width - 8);
                            {
                                for (int i = 0; i < uiNotificationManager.NotificationItems.Count; i++)
                                {
                                    QUI.BeginHorizontal(width - 8, QUI.SingleLineHeight);
                                    {
                                        if (NotificationItems.GetArrayElementAtIndex(i).FindPropertyRelative("notificationPrefab").objectReferenceValue != null)
                                        {
                                            NotificationItems.GetArrayElementAtIndex(i).FindPropertyRelative("notificationName").stringValue = NotificationItems.GetArrayElementAtIndex(i).FindPropertyRelative("notificationPrefab").objectReferenceValue.name;
                                        }
                                        else
                                        {
                                            NotificationItems.GetArrayElementAtIndex(i).FindPropertyRelative("notificationName").stringValue = "Missing Reference";
                                        }

                                        QLabel.text  = i + " - " + NotificationItems.GetArrayElementAtIndex(i).FindPropertyRelative("notificationName").stringValue;
                                        QLabel.style = Style.Text.Normal;

                                        QUI.Label(QLabel.text, Style.Text.Normal, 200);

                                        QUI.Space(2);

                                        QUI.PropertyField(NotificationItems.GetArrayElementAtIndex(i).FindPropertyRelative("notificationPrefab"), true, width - 200 - 2 - 16 - 12 - 8);

                                        if (QUI.ButtonMinus())
                                        {
                                            Undo.RecordObject(target, "ReferncedRemoved");
                                            uiNotificationManager.NotificationItems.RemoveAt(i);
                                            QUI.ExitGUI();
                                        }

                                        QUI.Space(8);
                                    }
                                    QUI.EndHorizontal();
                                }

                                QUI.BeginHorizontal(width - 8);
                                {
                                    QUI.FlexibleSpace();

                                    QUI.BeginVertical(16, QUI.SingleLineHeight);
                                    {
                                        if (QUI.ButtonPlus())
                                        {
                                            NotificationItems.InsertArrayElementAtIndex(NotificationItems.arraySize);
                                        }
                                        QUI.Space(1);
                                    }
                                    QUI.EndVertical();

                                    QUI.Space(4);
                                }
                                QUI.EndHorizontal();
                            }
                            QUI.EndVertical();

                            QUI.Space(2);

                            QUI.Space(4 * showUINotifications.faded);
                        }
                    }
                    QUI.EndVertical();
                }
                QUI.EndFadeGroup();
            }
            QUI.EndHorizontal();

            QUI.Space(SPACE_8);
        }
Example #4
0
        public static void DrawEditableLinkButtons(List <LinkButtonData> list, float width)
        {
#if !EZ_SOURCE
            return;
#endif
#pragma warning disable CS0162 // Unreachable code detected
            QUI.Space(SPACE_2);

            QUI.DrawIconBar("Edit Link Buttons", QResources.iconInfo, QColors.Color.Blue, IconPosition.Right, width, 20);
            if (list != null && list.Count > 0)
            {
                QUI.BeginChangeCheck();
                for (int i = 0; i < list.Count; i++)
                {
                    QUI.BeginHorizontal(width);
                    {
                        list[i].text = EditorGUILayout.DelayedTextField(list[i].text, GUILayout.Width(width * 0.4f));
                        QUI.Space(SPACE_2);
                        list[i].url = EditorGUILayout.DelayedTextField(list[i].url);
                        QUI.Space(SPACE_2);
                        list[i].linkButton = (Style.LinkButton)EditorGUILayout.EnumPopup(list[i].linkButton, GUILayout.Width(width * 0.1f));
                        QUI.Space(SPACE_2);
                        if (QUI.ButtonMinus())
                        {
                            list.RemoveAt(i);
                            QUI.SetDirty(EzSourceData.Instance);
                            AssetDatabase.SaveAssets();
                            QUI.ExitGUI();
                        }
                        QUI.Space(10);
                    }
                    QUI.EndHorizontal();
                }


                if (QUI.EndChangeCheck())
                {
                    QUI.SetDirty(EzSourceData.Instance);
                    AssetDatabase.SaveAssets();
                }
            }
            else
            {
                QUI.BeginHorizontal(width);
                {
                    QLabel q = new QLabel("There are no link buttons defined... This is not right!", Style.Text.Help);
                    QUI.Label(q);
                }
                QUI.EndHorizontal();
            }

            QUI.BeginHorizontal(width);
            {
                QUI.FlexibleSpace();
                if (QUI.ButtonPlus())
                {
                    list.Add(new LinkButtonData());
                    QUI.SetDirty(EzSourceData.Instance);
                    AssetDatabase.SaveAssets();
                }
                QUI.Space(6);
            }
            QUI.EndHorizontal();
#pragma warning restore CS0162 // Unreachable code detected
        }
        void DrawEnergyBars(float width)
        {
#if dUI_EnergyBarToolkit
            QUI.Space(SPACE_2);

            tempFloat = (20 + 2 + 18 * (sceneLoader.energyBars.Count + 1) + 2) * showEnergyBars.faded; //background height
            if (showEnergyBars.faded > 0.1f)
            {
                QUI.BeginHorizontal(width);
                {
                    QUI.Space(4 * showEnergyBars.faded);
                    QUI.Box(QStyles.GetBackgroundStyle(Style.BackgroundType.Low, sceneLoader.energyBars.Count > 0 ? QColors.Color.Purple : QColors.Color.Gray), width - 4, tempFloat);
                }
                QUI.EndHorizontal();
                QUI.Space(-tempFloat);
            }

            if (QUI.SlicedBar("Energy Bars", sceneLoader.energyBars.Count > 0 ? QColors.Color.Purple : QColors.Color.Gray, showEnergyBars, width, BarHeight))
            {
                showEnergyBars.target = !showEnergyBars.target;
            }

            QUI.BeginHorizontal(width);
            {
                QUI.Space(8 * showEnergyBars.faded);
                if (QUI.BeginFadeGroup(showEnergyBars.faded))
                {
                    QUI.BeginVertical(width - 8);
                    {
                        QUI.Space(2);

                        if (sceneLoader.energyBars.Count == 0)
                        {
                            QUI.BeginHorizontal(width - 8);
                            {
                                QLabel.text  = "No Energy Bars referenced... Click [+] to start...";
                                QLabel.style = Style.Text.Help;
                                QUI.BeginVertical(QLabel.x, QUI.SingleLineHeight);
                                {
                                    QUI.Label(QLabel);
                                    QUI.Space(2);
                                }
                                QUI.EndVertical();

                                QUI.FlexibleSpace();

                                QUI.BeginVertical(16, QUI.SingleLineHeight);
                                {
                                    if (QUI.ButtonPlus())
                                    {
                                        Undo.RecordObject(sceneLoader, "Added Energy Bar");
                                        sceneLoader.energyBars = new List <EnergyBar> {
                                            null
                                        };
                                    }
                                    QUI.Space(1);
                                }
                                QUI.EndVertical();

                                QUI.Space(4);
                            }
                            QUI.EndHorizontal();
                        }
                        else
                        {
                            QUI.BeginVertical(width - 8);
                            {
                                QLabel.style = Style.Text.Help;
                                for (int i = 0; i < sceneLoader.energyBars.Count; i++)
                                {
                                    QUI.BeginHorizontal(width - 8, QUI.SingleLineHeight);
                                    {
                                        QLabel.text = i.ToString();
                                        QUI.Label(QLabel);

                                        QUI.Space(2);

                                        sceneLoader.energyBars[i] = (EnergyBar)QUI.ObjectField(sceneLoader.energyBars[i], typeof(EnergyBar), true, width - QLabel.x - 2 - 16 - 12 - 8);

                                        if (QUI.ButtonMinus())
                                        {
                                            Undo.RecordObject(sceneLoader, "Removed Energy Bar");
                                            sceneLoader.energyBars.RemoveAt(i);
                                        }

                                        QUI.Space(8);
                                    }
                                    QUI.EndHorizontal();
                                }

                                QUI.BeginHorizontal(width - 8);
                                {
                                    QUI.FlexibleSpace();

                                    QUI.BeginVertical(16, QUI.SingleLineHeight);
                                    {
                                        if (QUI.ButtonPlus())
                                        {
                                            Undo.RecordObject(sceneLoader, "Added Energy Bar");
                                            sceneLoader.energyBars.Add(null);
                                        }
                                        QUI.Space(1);
                                    }
                                    QUI.EndVertical();

                                    QUI.Space(4);
                                }
                                QUI.EndHorizontal();
                            }
                            QUI.EndVertical();

                            QUI.Space(2);

                            QUI.Space(4 * showEnergyBars.faded);
                        }
                    }
                    QUI.EndVertical();
                }
                QUI.EndFadeGroup();
            }
            QUI.EndHorizontal();

            QUI.Space(SPACE_8);
#endif
        }
        void DrawStringList(List <string> list, float width, AnimBool aBool)
        {
            QUI.Space(SPACE_2 * aBool.faded);
            if (list.Count == 0)
            {
                if (SearchPatternAnimBool.value)
                {
                    DrawInfoMessage(InfoMessageName.NoResults.ToString(), width);
                }
                else
                {
                    QUI.BeginHorizontal(width);
                    {
                        QUI.Space(SPACE_8 * aBool.faded);
                        DrawInfoMessage(InfoMessageName.EmptyList.ToString(), width - SPACE_8);
                        QUI.Space(-20);
                        QUI.BeginVertical(16, 20);
                        {
                            QUI.Space(SPACE_4);
                            if (QUI.ButtonPlus())
                            {
                                Undo.RecordObject(DUIData.Instance, "Update List");
                                list.Add("");
                                QUI.SetDirty(DUIData.Instance);
                                AssetDatabase.SaveAssets();
                            }
                        }
                        QUI.EndVertical();
                        QUI.FlexibleSpace();
                    }
                    QUI.EndHorizontal();
                }
                return;
            }

            QUI.BeginVertical(width);
            {
                bool matchFoundInThisCategory = false;
                for (int i = 0; i < list.Count; i++)
                {
                    if (SearchPatternAnimBool.target) //a search pattern has been entered in the search box
                    {
                        if (!Regex.IsMatch(list[i], SearchPattern, RegexOptions.IgnoreCase))
                        {
                            continue; //this does not match the search pattern --> we do not show this name it
                        }
                        matchFoundInThisCategory = true;
                    }

                    QUI.BeginHorizontal(width);
                    {
                        QUI.Space(SPACE_8 * aBool.faded);
                        if (SearchPatternAnimBool.target) //in search mode, show a Label
                        {
                            QUI.Label(list[i], Style.Text.Normal, (width - SPACE_8));
                        }
                        else //search is disabled, show a text field
                        {
                            string tempString = list[i];
                            QUI.BeginChangeCheck();
                            tempString = EditorGUILayout.DelayedTextField(tempString, GUILayout.Width(width - SPACE_8 - 18));
                            if (QUI.EndChangeCheck())
                            {
                                if (list.Contains(tempString))
                                {
                                    QUI.DisplayDialog("Attention Required",
                                                      "There is another entry in this list with the same name.",
                                                      "Ok");
                                }
                                else
                                {
                                    Undo.RecordObject(DUIData.Instance, "Update List");
                                    list[i] = tempString;
                                    list.Sort();
                                    QUI.SetDirty(DUIData.Instance);
                                    AssetDatabase.SaveAssets();
                                }
                            }

                            if (QUI.ButtonMinus())
                            {
                                Undo.RecordObject(DUIData.Instance, "Update List");
                                list.RemoveAt(i);
                                QUI.SetDirty(DUIData.Instance);
                                AssetDatabase.SaveAssets();
                            }
                        }
                        QUI.FlexibleSpace();
                    }
                    QUI.EndHorizontal();
                    QUI.Space(SPACE_2 * aBool.faded - (SearchPatternAnimBool.target ? SPACE_2 : 0));
                }

                if (SearchPatternAnimBool.target)
                {
                    if (!matchFoundInThisCategory) //if a search pattern is active and no valid names were found for this category we let the developer know
                    {
                        DrawInfoMessage(InfoMessageName.NoResults.ToString(), width);
                    }
                    QUI.Space(18);
                }
                else //because a search pattern is active, we do not give the developer the option to create a new name
                {
                    QUI.BeginHorizontal(width);
                    {
                        QUI.Space(SPACE_8 * aBool.faded);
                        QUI.Space(width - SPACE_8 - 14);
                        if (QUI.ButtonPlus())
                        {
                            Undo.RecordObject(DUIData.Instance, "Update List");
                            list.Add("");
                            QUI.SetDirty(DUIData.Instance);
                            AssetDatabase.SaveAssets();
                        }
                    }
                    QUI.EndHorizontal();
                }
            }
            QUI.EndVertical();
        }
Example #7
0
        void DrawEnergyBars()
        {
#if dUI_EnergyBarToolkit
            QUI.DrawTexture(DUIResources.barEnergyBars.texture, WIDTH_420, 18);
            SaveColors();
            QUI.SetGUIBackgroundColor(DUIColors.PurpleLight.Color);
            QUI.Space(SPACE_2);
            if (sceneLoader.energyBars == null || sceneLoader.energyBars.Count == 0)
            {
                QUI.BeginHorizontal(WIDTH_420);
                {
                    QUI.Label("No Energy Bars referenced... Click [+] to start...", WIDTH_420 - 27);
                    QUI.BeginVertical(18);
                    {
                        QUI.Space(-1);
                        if (QUI.ButtonPlus())
                        {
                            Undo.RecordObject(sceneLoader, "Added Energy Bar");
                            sceneLoader.energyBars = new List <EnergyBar> {
                                null
                            };
                        }
                    }
                    QUI.EndVertical();
                }
                QUI.EndHorizontal();
                QUI.Space(SPACE_8);
                return;
            }

            QUI.BeginVertical(WIDTH_420);
            {
                for (int i = 0; i < sceneLoader.energyBars.Count; i++)
                {
                    QUI.BeginHorizontal(WIDTH_420);
                    {
                        QUI.Space(-4);
                        QUI.Label(" " + i.ToString(), 22);
                        QUI.ObjectField(sceneLoader.energyBars[i], typeof(EnergyBar), true, WIDTH_420 - 18 - 18 - 13);
                        QUI.BeginVertical(18);
                        {
                            QUI.Space(-1);
                            if (QUI.ButtonMinus())
                            {
                                Undo.RecordObject(sceneLoader, "Removed Energy Bar");
                                sceneLoader.energyBars.RemoveAt(i);
                            }
                        }
                        QUI.EndVertical();
                    }
                    QUI.EndHorizontal();
                }

                QUI.BeginHorizontal(WIDTH_420);
                {
                    QUI.Space(WIDTH_420 - 23);
                    QUI.BeginVertical(18);
                    {
                        QUI.Space(-1);
                        if (QUI.ButtonPlus())
                        {
                            Undo.RecordObject(sceneLoader, "Added Energy Bar");
                            sceneLoader.energyBars.Add(null);
                        }
                    }
                    QUI.EndVertical();
                    QUI.Space(2);
                }
                QUI.EndHorizontal();
            }
            QUI.EndVertical();
            QUI.Space(SPACE_8);
            RestoreColors();
#endif
        }
        void DrawNotificationItems()
        {
            if (NotificationItems.arraySize == 0)
            {
                QUI.BeginHorizontal(WIDTH_420);
                {
                    QUI.Label("No UINotification prefabs referenced... Click [+] to start...", WIDTH_420 - 23);
                    QUI.BeginVertical(18);
                    {
                        QUI.Space(-1);
                        if (QUI.ButtonPlus())
                        {
                            NotificationItems.InsertArrayElementAtIndex(0);
                        }
                    }
                    QUI.EndVertical();
                }
                QUI.EndHorizontal();
                return;
            }

            QUI.BeginHorizontal(WIDTH_420);
            {
                QUI.Space(18);
                QUI.Label("Notification Name", DUIStyles.GetStyle(DUIStyles.TextStyle.LabelNormalItalic), (WIDTH_420 - 18 - 18 - 9) / 2f);
                QUI.Label("Notification Prefab", DUIStyles.GetStyle(DUIStyles.TextStyle.LabelNormalItalic), (WIDTH_420 - 18 - 18 - 9) / 2f);
            }
            QUI.EndHorizontal();

            QUI.BeginVertical(WIDTH_420);
            {
                for (int i = 0; i < NotificationItems.arraySize; i++)
                {
                    SaveColors();
                    QUI.BeginHorizontal(WIDTH_420);
                    {
                        QUI.Space(-4);
                        QUI.Label(" " + i.ToString(), 18);
                        if (NotificationItems.GetArrayElementAtIndex(i).FindPropertyRelative("notificationPrefab").objectReferenceValue != null)
                        {
                            NotificationItems.GetArrayElementAtIndex(i).FindPropertyRelative("notificationName").stringValue = NotificationItems.GetArrayElementAtIndex(i).FindPropertyRelative("notificationPrefab").objectReferenceValue.name;
                        }
                        else
                        {
                            QUI.SetGUIBackgroundColor(DUIColors.RedLight.Color);
                            QUI.SetGUIColor(DUIColors.RedLight.Color);
                            NotificationItems.GetArrayElementAtIndex(i).FindPropertyRelative("notificationName").stringValue = "Missing UINotification prefab";
                        }
                        QUI.Label(NotificationItems.GetArrayElementAtIndex(i).FindPropertyRelative("notificationName").stringValue, (WIDTH_420 - 18 - 18 - 9) / 2f);
                        QUI.PropertyField(NotificationItems.GetArrayElementAtIndex(i).FindPropertyRelative("notificationPrefab"), true, (WIDTH_420 - 18 - 18 - 9) / 2f);
                        QUI.BeginVertical(18);
                        {
                            QUI.Space(-1);
                            if (QUI.ButtonMinus())
                            {
                                NotificationItems.DeleteArrayElementAtIndex(i);
                            }
                        }
                        QUI.EndVertical();
                    }
                    QUI.EndHorizontal();
                    RestoreColors();
                }

                QUI.BeginHorizontal(WIDTH_420);
                {
                    QUI.Space(WIDTH_420 - 19);
                    QUI.BeginVertical(18);
                    {
                        QUI.Space(-1);
                        if (QUI.ButtonPlus())
                        {
                            NotificationItems.InsertArrayElementAtIndex(NotificationItems.arraySize);
                        }
                    }
                    QUI.EndVertical();
                    QUI.Space(2);
                }
                QUI.EndHorizontal();
            }
            QUI.EndVertical();
        }
Example #9
0
        void InitDefineSymbols()
        {
            defineSymbolsNewPreset = new AnimBool(false, Repaint);

            selectedBuildTargetGroup           = QUtils.GetActiveBuildTargetGroup();
            previouslySelectedBuildTargetGroup = selectedBuildTargetGroup;

            selectedBuildTargetGroupIsTheActivePlatform = new AnimBool(selectedBuildTargetGroup == QUtils.GetActiveBuildTargetGroup(), Repaint);

            if (symbols == null)
            {
                symbols = new List <string>();
            }
            else
            {
                symbols.Clear();
            }
            symbols = QUtils.GetScriptingDefineSymbolsForGroup(selectedBuildTargetGroup);
            if (presetSymbols == null)
            {
                presetSymbols = new List <string>();
            }
            else
            {
                presetSymbols.Clear();
            }
            presetSymbols.AddRange(symbols);

            presetSymbolsReordableList = new ReorderableList(presetSymbols, typeof(string), true, false, false, false)
            {
                showDefaultBackground         = false,
                drawElementBackgroundCallback = (rect, index, active, focused) => { }
            };
            presetSymbolsReordableList.drawElementCallback = (rect, index, active, focused) =>
            {
                if (index == presetSymbolsReordableList.list.Count)
                {
                    return;
                }
                float width          = WindowSettings.CurrentPageContentWidth / 2;
                int   dragBumbWidth  = 0;
                int   buttonWidth    = 16;
                int   textFieldWidth = (int)width - 20 - buttonWidth - 2 - buttonWidth;
                rect.x += dragBumbWidth;
                QUI.SetGUIBackgroundColor(EditorGUIUtility.isProSkin ? QColors.Green.Color : QColors.GreenLight.Color);
                presetSymbolsReordableList.list[index] = EditorGUI.TextField(new Rect(rect.x, rect.y, textFieldWidth, EditorGUIUtility.singleLineHeight), (string)presetSymbolsReordableList.list[index]);
                QUI.ResetColors();
                rect.x += textFieldWidth;
                rect.x += 2;
                rect.y -= 1;
                if (QUI.ButtonMinus(rect))
                {
                    if (index == 0 && presetSymbolsReordableList.list.Count == 1) //is this the last list entry?
                    {
                        presetSymbolsReordableList.list[index] = "";              //yes --> add an empty entry
                    }
                    else
                    {
                        presetSymbolsReordableList.list.Remove(presetSymbolsReordableList.list[index]); //no --> remove the entry
                    }
                }
                rect.x += buttonWidth;
                rect.x += 2;
                if (QUI.ButtonPlus(rect))
                {
                    presetSymbolsReordableList.list.Insert(index, ""); //add a new empty entry
                }
            };

            selectedPresetName = DEFAULT_PRESET_NAME;
            loadedPresetName   = selectedPresetName;
            RefreshPresetNames();
        }
Example #10
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();
        }
Example #11
0
 private void DrawPrefabs()
 {
     // 先画个盒子,再提上去写文字
     QUI.Space(SPACE_8);
     QUI.Box(QStyles.GetBackgroundStyle(Style.BackgroundType.Low, QColors.Color.Orange), WIDTH_420, 20);
     QUI.Space(-20);
     QUI.BeginHorizontal(WIDTH_420);
     {
         QUI.Space(SPACE_4);
         QUI.Label("PREFAB" + ((poolySpawner.spawnPrefabs != null && poolySpawner.spawnPrefabs.Count > 1) ? "S" : "") + " TO SPAWN(拖预制体进来)", Style.Text.Normal, 200, HEIGHT_16);
         QUI.Space(SPACE_4);
         QUI.FlexibleSpace();
         if (poolySpawner.spawnPrefabs != null && poolySpawner.spawnPrefabs.Count > 1)
         {
             QUI.Label("Spawn Type", Style.Text.Normal, 68);
             QUI.SetGUIBackgroundColor(AccentColorOrange);
             QUI.Popup(prefabSpawnType, 80, SpawnTypes);
             QUI.ResetColors();
         }
         QUI.Space(SPACE_8);
     }
     QUI.EndHorizontal();
     QUI.Space(SPACE_4);
     if (poolySpawner.spawnPrefabs == null || poolySpawner.spawnPrefabs.Count == 0)
     {
         poolySpawner.spawnPrefabs = new List <PoolySpawner.SpawnPrefab> {
             new PoolySpawner.SpawnPrefab(null)
         };
     }
     if (poolySpawner.spawnPrefabs.Count == 1 && poolySpawner.prefabSpawnType == PoolySpawner.SpawnType.Random)
     {
         poolySpawner.prefabSpawnType = PoolySpawner.SpawnType.Sequential;
     }
     infoMessage["NoPrefabs"].show.target = !poolySpawner.HasPrefabs();
     // 画框框提示
     DrawInfoMessage("NoPrefabs", WIDTH_420 - 20);
     for (int i = 0; i < poolySpawner.spawnPrefabs.Count; i++)
     {
         QUI.Space(SPACE_2);
         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 prefabObject = poolySpawner.spawnPrefabs[i].prefab;
             QUI.SetGUIBackgroundColor(AccentColorOrange);
             prefabObject = (Transform)QUI.ObjectField(prefabObject, typeof(Transform), false, (WIDTH_420 - SPACE_2 - tempContentSize.x - SPACE_8 - SPACE_16) - 240 * animBoolSpawnRandomPrefab.faded);
             QUI.ResetColors();
             if (QUI.EndChangeCheck())
             {
                 Undo.RecordObject(poolySpawner, "Changed Value For Prefab Slot " + i);
                 poolySpawner.spawnPrefabs[i].prefab = prefabObject;
             }
             if (QUI.ButtonMinus())
             {
                 if (poolySpawner.spawnPrefabs.Count > 1)
                 {
                     Undo.RecordObject(poolySpawner, "Removed Prefab Slot " + i);
                     poolySpawner.spawnPrefabs.RemoveAt(i);
                 }
                 else if (poolySpawner.spawnPrefabs == null || poolySpawner.spawnPrefabs[0].prefab != null)
                 {
                     Undo.RecordObject(poolySpawner, "Reset Prefab Slot");
                     poolySpawner.spawnPrefabs = new List <PoolySpawner.SpawnPrefab> {
                         new PoolySpawner.SpawnPrefab(null)
                     };
                 }
                 QUI.SetDirty(poolySpawner);
                 QUI.ExitGUI();
             }
             animBoolSpawnRandomPrefab.target = prefabSpawnType.enumValueIndex == (int)PoolySpawner.SpawnType.Random;
             if (poolySpawner.spawnPrefabs != null && poolySpawner.spawnPrefabs.Count > 1 && prefabSpawnType.enumValueIndex == (int)PoolySpawner.SpawnType.Random)
             {
                 QUI.Space(SPACE_2);
                 QUI.Label("weight", Style.Text.Small, 50 * animBoolSpawnRandomPrefab.faded);
                 QUI.Space(-SPACE_8);
                 QUI.BeginChangeCheck();
                 int spawnPrefabWeight = poolySpawner.spawnPrefabs[i].weight;
                 QUI.SetGUIBackgroundColor(AccentColorOrange);
                 spawnPrefabWeight = EditorGUILayout.IntSlider(spawnPrefabWeight, 0, 100);
                 QUI.ResetColors();
                 if (QUI.EndChangeCheck())
                 {
                     Undo.RecordObject(poolySpawner, "Changed Weight Of Prefab " + i);
                     poolySpawner.spawnPrefabs[i].weight = spawnPrefabWeight;
                 }
             }
             QUI.FlexibleSpace();
         }
         QUI.EndHorizontal();
     }
     QUI.Space(SPACE_2);
     QUI.BeginHorizontal(WIDTH_420);
     {
         QUI.FlexibleSpace();
         if (QUI.ButtonPlus())
         {
             Undo.RecordObject(poolySpawner, "Added New Prefab Slot");
             poolySpawner.spawnPrefabs.Add(new PoolySpawner.SpawnPrefab(null));
             QUI.SetDirty(poolySpawner);
             QUI.ExitGUI();
         }
         QUI.Space(3 + 240 * animBoolSpawnRandomPrefab.faded);
     }
     QUI.EndHorizontal();
 }