private void DrawBuildConfigSettings(BuildConfig.BuildConfig buildConfig, BuildConfigSettings settings, SerializedProperty settingsSerializedProperty, bool isInherited, float currentViewWidth, out bool didDeleteSettings)
        {
            didDeleteSettings = false;

            bool foldoutVisible = true;
            Rect boxRect        = new Rect();

            var verticleHelper = settings.IsInline ?
                                 (IDisposable) new EditorGUILayout.HorizontalScope("box") :
                                 (IDisposable) new FoldoutScope(settings.DisplayName.GetHashCode(), settings.DisplayName, out foldoutVisible, out boxRect, false);

            using (verticleHelper)
            {
                float y = settings.IsInline ? (verticleHelper as EditorGUILayout.HorizontalScope).rect.y : boxRect.y;

                // Drawing the button
                float buttonSize   = 14;
                float rightPadding = 25;
                float topPadding   = 2;

                Rect buttonRect = new Rect(new Vector2(currentViewWidth - rightPadding, y + topPadding), new Vector2(buttonSize, buttonSize));

                if (isInherited)
                {
                    if (ButtonUtil.DrawAddButton(buttonRect))
                    {
                        buildConfig.Settings.Add(Activator.CreateInstance(settings.GetType()) as BuildConfigSettings);
                    }
                }
                else
                {
                    if (ButtonUtil.DrawDeleteButton(buttonRect))
                    {
                        buildConfig.Settings.Remove(settings);
                        didDeleteSettings = true;
                        return;
                    }
                }

                // Breaking out if we're not suppose to show the foldout
                if (foldoutVisible == false)
                {
                    return;
                }

                // Iterating and displaying all properties
                using (new EditorGUI.DisabledGroupScope(isInherited))
                {
                    float width = currentViewWidth - (settings.IsInline ? 60 : 15);
                    settings.DrawSettings(settings, settingsSerializedProperty, width);
                }
            }
        }
Beispiel #2
0
        private void DrawAppConfigSettings(AppConfig appConfig, AppConfigSettings settings, bool isInherited, out bool didDeleteSettings)
        {
            didDeleteSettings = false;

            float currentViewWidth = EditorGUIUtility.currentViewWidth - 20;
            bool  foldoutVisible   = true;
            Rect  boxRect          = new Rect();

            var verticleHelper = settings.IsInline ?
                                 (IDisposable) new EditorGUILayout.HorizontalScope("box") :
                                 (IDisposable) new FoldoutScope(settings.DisplayName.GetHashCode(), settings.DisplayName, out foldoutVisible, out boxRect, false);

            using (verticleHelper)
            {
                float y = settings.IsInline ? (verticleHelper as EditorGUILayout.HorizontalScope).rect.y : boxRect.y;

                // Drawing the button
                float buttonSize   = 14;
                float rightPadding = 7;
                float topPadding   = 1;

                Rect buttonRect = new Rect(new Vector2(currentViewWidth - rightPadding, y + topPadding), new Vector2(buttonSize, buttonSize));

                if (isInherited)
                {
                    if (ButtonUtil.DrawAddButton(buttonRect))
                    {
                        var newSettings = UnityEngine.Object.Instantiate(settings) as AppConfigSettings;
                        appConfig.Settings.Add(newSettings);

                        string path = appConfig.GetPath();
                        AssetDatabase.AddObjectToAsset(newSettings, path);
                        AssetDatabase.ImportAsset(path);
                    }
                }
                else
                {
                    if (ButtonUtil.DrawDeleteButton(buttonRect))
                    {
                        appConfig.Settings.Remove(settings);
                        GameObject.DestroyImmediate(settings, true);
                        AssetDatabase.ImportAsset(appConfig.GetPath());
                        didDeleteSettings = true;
                        return;
                    }
                }

                // Breaking out if we're not suppose to show the foldout
                if (foldoutVisible == false)
                {
                    return;
                }

                // Iterating and displaying all properties
                using (new EditorGUI.DisabledGroupScope(isInherited))
                {
                    float width = currentViewWidth - (settings.IsInline ? 34 : 15);
                    settings.DrawSettings(settings, width);
                }
            }
        }
Beispiel #3
0
        public virtual void OnGUI()
        {
            if (this.titleDataObject == null || this.serializedObject == null || this.serializedProperty == null)
            {
                GUILayout.Label("Please Re-open the editor.");
                return;
            }

            if (this.activeDataVersionIndex < 0 || this.activeDataVersionIndex >= this.titleDataObject.Versions.Count)
            {
                this.activeDataVersionIndex = this.titleDataObject.Versions.Count - 1;
            }


            using (var changeCheck = new EditorGUI.ChangeCheckScope())
            {
                using (new GUILayout.VerticalScope("box", GUILayout.ExpandWidth(true)))
                {
                    using (new GUILayout.HorizontalScope(GUILayout.ExpandWidth(true)))
                    {
                        // TitleDataKeyName
                        GUILayout.Label("TitleData Key", GUILayout.Width(80));
                        this.titleDataObject.TitleDataKeyName = GUILayout.TextField(this.titleDataObject.TitleDataKeyName, GUILayout.Width(200));
                        GUILayout.Space(10);

                        // SerializeWithUnity
                        this.titleDataObject.SerializeWithUnity = GUILayout.Toggle(this.titleDataObject.SerializeWithUnity, "Serialize With Unity", GUILayout.Width(140));

                        // CompressData
                        this.titleDataObject.CompressData = GUILayout.Toggle(this.titleDataObject.CompressData, "Compress Data", GUILayout.Width(150));

                        GUILayout.FlexibleSpace();

                        // Upload Button
                        if (GUILayout.Button("Upload", GUILayout.Width(100)))
                        {
                            string json = string.Empty;

                            if (this.titleDataObject.SerializeWithUnity)
                            {
                                json = JsonUtility.ToJson(this.titleDataObject.Data[this.activeDataVersionIndex]);
                            }
                            else
                            {
                                json = PlayFabManager.SerializerPlugin.SerializeObject(this.titleDataObject.Data[this.activeDataVersionIndex]);
                            }

                            if (this.titleDataObject.CompressData)
                            {
                                json = LZString.CompressToBase64(json);
                            }

                            string titleDataKey = string.Format("{0}_{1}", this.titleDataObject.TitleDataKeyName, this.titleDataObject.Versions[this.activeDataVersionIndex]);
                            PlayFabEditorAdmin.SetTitleDataAndPrintErrorOrSuccess(titleDataKey, json);
                        }
                    }

                    using (new GUILayout.HorizontalScope(GUILayout.ExpandWidth(true)))
                    {
                        GUILayout.Label("Version", GUILayout.Width(60));
                        this.activeDataVersionIndex = EditorGUILayout.Popup(this.activeDataVersionIndex, this.GetVersions(), GUILayout.Width(80));

                        // Drawing Add Button
                        if (ButtonUtil.DrawAddButton(new Rect(new Vector2(155, 24), new Vector2(15, 15))))
                        {
                            this.serializedObject.FindProperty("data").arraySize++;
                            this.serializedObject.FindProperty("versions").arraySize++;
                            this.serializedObject.ApplyModifiedProperties();

                            // Making sure we select the newly created version
                            this.activeDataVersionIndex = this.titleDataObject.Versions.Count - 1;
                        }

                        // Drawing Delete Button
                        if (this.titleDataObject.Versions.Count > 1)
                        {
                            if (ButtonUtil.DrawDeleteButton(new Rect(new Vector2(175, 24), new Vector2(15, 15))))
                            {
                                this.serializedObject.FindProperty("data").DeleteArrayElementAtIndex(this.activeDataVersionIndex);
                                this.serializedObject.FindProperty("versions").DeleteArrayElementAtIndex(this.activeDataVersionIndex);
                                this.serializedObject.ApplyModifiedProperties();
                                return;
                            }
                        }
                    }
                }

                using (var horizontalScope = new GUILayout.HorizontalScope("box", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
                {
                    using (var scrollViewScope = new EditorGUILayout.ScrollViewScope(scrollBarPosition))
                    {
                        scrollBarPosition = scrollViewScope.scrollPosition;

                        EditorGUILayout.Space();

                        // Drawing the Version String
                        using (new LabelWidthScope(60))
                        {
                            string version    = this.titleDataObject.Versions[this.activeDataVersionIndex];
                            string newVersion = EditorGUILayout.TextField("Version", version);

                            if (version != newVersion)
                            {
                                this.titleDataObject.Versions[this.activeDataVersionIndex] = newVersion;
                            }
                        }

                        // Drawing everything else (user defined)
                        this.DrawData(this.titleDataObject.Data[this.activeDataVersionIndex], this.serializedObject, this.serializedProperty.GetArrayElementAtIndex(this.activeDataVersionIndex));
                    }
                }

                // Making sure we mark the data dirty if it changed
                if (changeCheck.changed)
                {
                    EditorUtility.SetDirty(this.serializedObject.targetObject);
                    this.serializedObject.ApplyModifiedProperties();
                }
            }
        }