Пример #1
0
        private void OnGUI()
        {
            if (this._encounterInfo != null)
            {
                if (EditorWindowBase.GetButton("Add Text", 80, Color.green))
                {
                    this._encounterInfo.Texts.Add(new LocalizableString());
                    this._encounterInfo.Texts.Last().Text = string.Empty;
                }

                this._scrollPos = EditorGUILayout.BeginScrollView(this._scrollPos);

                GUILayout.Space(10);

                if (this._encounterInfo.Texts.Count > 0)
                {
                    int indexToDeleteText = -1;
                    for (int i = 0; i < this._encounterInfo.Texts.Count; i++)
                    {
                        var text = this._encounterInfo.Texts[i];
                        if (text != null)
                        {
                            EditorGUILayout.BeginHorizontal();
                            EditorStyles.textField.wordWrap = true;
                            text.Text = EditorGUILayout.TextArea(text.Text, GUILayout.Width(400), GUILayout.Height(100));

                            if (EditorWindowBase.GetButton("-", 20, Color.red))
                            {
                                indexToDeleteText = i;
                            }

                            EditorGUILayout.EndHorizontal();

                            if (indexToDeleteText > -1)
                            {
                                bool result = EditorUtility.DisplayDialog("Delete", "Delete Text",
                                                                          "OK", "Cancel");
                                if (result)
                                {
                                    this._encounterInfo.Texts.RemoveAt(indexToDeleteText);
                                }

                                indexToDeleteText = -1;
                                this.Repaint();
                            }
                        }
                    }
                }

                EditorGUILayout.EndScrollView();
            }
        }
Пример #2
0
        private void OnGUI()
        {
            if (this._encounterInfo != null)
            {
                this._allowerTypeIndex = EditorGUILayout.Popup(this._allowerTypeIndex, this._allowerTypeNames);

                if (EditorWindowBase.GetButton("Add Allower", 80, Color.green))
                {
                    if (this._allowerTypeIndex < 0)
                    {
                        return;
                    }

                    AllowerInfoBase allowerInfoBase = CreateInstance(this._allowerTypeNames[this._allowerTypeIndex]) as AllowerInfoBase;
                    if (allowerInfoBase != null)
                    {
                        this._encounterInfo.Allowers.Add(allowerInfoBase);
                        CustomEditorUtils.AddAssetToAsset(allowerInfoBase, this._encounterInfo);
                    }
                    else
                    {
                        throw new ArgumentException("component is NULL.");
                    }
                }

                this._scrollPos = EditorGUILayout.BeginScrollView(this._scrollPos);

                GUILayout.Space(10);

                if (this._encounterInfo.Allowers.Count > 0)
                {
                    int indexToDelete = -1;
                    for (int i = 0; i < this._encounterInfo.Allowers.Count; i++)
                    {
                        var allower = this._encounterInfo.Allowers[i];
                        if (allower != null)
                        {
                            EditorGUILayout.BeginVertical(GUI.skin.box);
                            Editor.CreateEditor(this._encounterInfo.Allowers[i]).OnInspectorGUI();

                            if (EditorWindowBase.GetButton("-", 20, Color.red))
                            {
                                indexToDelete = i;
                            }

                            EditorGUILayout.EndVertical();

                            if (indexToDelete > -1)
                            {
                                bool result = EditorUtility.DisplayDialog("Delete", "Delete Event",
                                                                          "OK", "Cancel");
                                if (result)
                                {
                                    this._encounterInfo.Allowers.Remove(this._encounterInfo.Allowers[indexToDelete]);
                                    DestroyImmediate(this._encounterInfo.Allowers[indexToDelete], true);

                                    AssetDatabase.SaveAssets();
                                    AssetDatabase.Refresh();
                                }

                                this.Repaint();
                            }
                        }
                    }
                }

                EditorGUILayout.EndScrollView();
            }
        }