Example #1
0
 public void OnEnable()
 {
     if (tdEditor == null)
     {
         tdEditor = ScriptableObject.CreateInstance <TitleDataEditor>();
     }
 }
        public static void  ShowWindow(TitleDataEditor tdInstance)
        {
            // myInstance tdInstance;
            myInstance = tdInstance;

            myWindow       = EditorWindow.GetWindow <TitleDataEditor>();
            myWindow.key   = tdInstance.key;
            myWindow.Value = string.IsNullOrEmpty(tdInstance.Value) ? "ENTER A VALUE" : tdInstance.Value;

            myWindow.Show();
        }
Example #3
0
 public void OnDestroy()
 {
     tdEditor = null;
 }
Example #4
0
        // this gets called after the Base draw loop
        public void Draw()
        {
            EditorGUILayout.BeginHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1"));
            GUILayout.Label("TitleData provides Key-Value storage available to all API sets. TitleData is designed to store game-wide configuration data.", PlayFabEditorHelper.uiStyle.GetStyle("genTxt"));
            GUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("REFRESH", PlayFabEditorHelper.uiStyle.GetStyle("Button")))
            {
                RefreshRecords();
            }

            if (GUILayout.Button("+", PlayFabEditorHelper.uiStyle.GetStyle("Button"), GUILayout.MaxWidth(25)))
            {
                AddRecord();
            }

            EditorGUILayout.EndHorizontal();

            if (items.Count > 0)
            {
                scrollPos = GUILayout.BeginScrollView(scrollPos, PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1"));
                float keyInputBoxWidth   = EditorGUIUtility.currentViewWidth > 200 ? 170 : (EditorGUIUtility.currentViewWidth - 100) / 2;
                float valueInputBoxWidth = EditorGUIUtility.currentViewWidth > 200 ? EditorGUIUtility.currentViewWidth - 290 : (EditorGUIUtility.currentViewWidth - 100) / 2;

                for (var z = 0; z < this.items.Count; z++)
                {
                    this.items[z].DataEditedCheck();
                    if (items[z].isDirty)
                    {
                        showSave = true;
                    }

                    if (items[z].Value != null)
                    {
                        //GUIContent c1 = new GUIContent(items[z].Value);
                        //Rect r1 = GUILayoutUtility.GetRect(c1, EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).GetStyle("TextArea"));

                        var keyStyle = this.items[z].isDirty ?  PlayFabEditorHelper.uiStyle.GetStyle("listKey_dirty") :PlayFabEditorHelper.uiStyle.GetStyle("listKey");
                        var valStyle = this.items[z].isDirty ?  PlayFabEditorHelper.uiStyle.GetStyle("listValue_dirty") : PlayFabEditorHelper.uiStyle.GetStyle("listValue");
                        //var h = style.CalcHeight(c1, valueInputBoxWidth);


                        EditorGUILayout.BeginHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear"));



                        items[z].Key = GUILayout.TextField(items[z].Key, keyStyle, GUILayout.Width(keyInputBoxWidth));

                        EditorGUILayout.LabelField(":", GUILayout.MaxWidth(10));
                        GUILayout.Label("" + items[z].Value, valStyle, GUILayout.MaxWidth(valueInputBoxWidth), GUILayout.MaxHeight(25));

                        if (GUILayout.Button("EDIT", PlayFabEditorHelper.uiStyle.GetStyle("Button"), GUILayout.MaxHeight(19), GUILayout.MinWidth(35)))
                        {
                            if (tdEditor == null)
                            {
                                tdEditor = EditorWindow.GetWindow <TitleDataEditor>();
                                tdEditor.titleContent = new GUIContent("Title Data");
                                tdEditor.minSize      = new Vector2(300, 400);
                            }

                            tdEditor.LoadData(items[z].Key, items[z].Value);
                            tdEditor.Show();
                        }
                        if (GUILayout.Button("X", PlayFabEditorHelper.uiStyle.GetStyle("Button"), GUILayout.MaxHeight(19), GUILayout.MinWidth(20)))
                        {
                            items[z].isDirty = true;
                            items[z].Value   = null;
                        }

                        EditorGUILayout.EndHorizontal();
                    }
                }


                GUILayout.EndScrollView();//EditorGUILayout.EndVertical();

                if (showSave)
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("SAVE", PlayFabEditorHelper.uiStyle.GetStyle("Button"), GUILayout.MaxWidth(200)))
                    {
                        //BaseUiAnimationController.StartAlphaFade(1, 0, listDisplay);
                        SaveRecords();
                    }
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndHorizontal();
                }
            }


            // draw code here.
            // base.PostDraw();
        }