Exemplo n.º 1
0
        // - Misc Functionality -
        private void ResetModMedia()
        {
            EditorUtilityExtensions.SetSerializedPropertyStringArray(youTubeURLsProp.FindPropertyRelative("value"),
                                                                     profile.media.youTubeURLs);
            youTubeURLsProp.FindPropertyRelative("isDirty").boolValue = false;

            EditorUtilityExtensions.SetSerializedPropertyStringArray(sketchfabURLsProp.FindPropertyRelative("value"),
                                                                     profile.media.sketchfabURLs);
            sketchfabURLsProp.FindPropertyRelative("isDirty").boolValue = false;

            // - Images -
            SerializedProperty galleryImagesArray = galleryImagesProp.FindPropertyRelative("value");

            galleryImagesArray.arraySize = profile.media.galleryImageLocators.Length;
            for (int i = 0; i < profile.media.galleryImageLocators.Length; ++i)
            {
                galleryImagesArray.GetArrayElementAtIndex(i).FindPropertyRelative("fileName").stringValue = profile.media.galleryImageLocators[i].GetFileName();
                galleryImagesArray.GetArrayElementAtIndex(i).FindPropertyRelative("url").stringValue      = profile.media.galleryImageLocators[i].GetURL();
            }

            galleryImagesProp.FindPropertyRelative("isDirty").boolValue = false;
        }
Exemplo n.º 2
0
        protected virtual void LayoutTagsField()
        {
            using (new EditorGUI.DisabledScope(this.gameProfile == null))
            {
                EditorGUILayout.BeginHorizontal();
                this.isTagsExpanded = EditorGUILayout.Foldout(this.isTagsExpanded, "Tags", true);
                GUILayout.FlexibleSpace();
                bool isUndoRequested = EditorGUILayoutExtensions.UndoButton(isUndoEnabled);
                EditorGUILayout.EndHorizontal();

                if (this.isTagsExpanded)
                {
                    if (this.gameProfile == null)
                    {
                        EditorGUILayout.HelpBox("The Game's Profile is not yet loaded, and thus tags cannot be displayed. Please wait...", MessageType.Warning);
                    }
                    else if (this.gameProfile.tagCategories.Length == 0)
                    {
                        EditorGUILayout.HelpBox("The developers of "
                                                + this.gameProfile.name
                                                + " have not designated any tagging options",
                                                MessageType.Info);
                    }
                    else
                    {
                        var  tagsProperty    = editableProfileProperty.FindPropertyRelative("tags.value");
                        var  oldSelectedTags = new List <string>(EditorUtilityExtensions.GetSerializedPropertyStringArray(tagsProperty));
                        var  newSelectedTags = new List <string>();
                        bool isDirty         = false;

                        ++EditorGUI.indentLevel;
                        foreach (ModTagCategory tagCategory in this.gameProfile.tagCategories)
                        {
                            if (!tagCategory.isHidden)
                            {
                                using (var check = new EditorGUI.ChangeCheckScope())
                                {
                                    var categoryTags = LayoutTagCategoryField(tagCategory, oldSelectedTags);
                                    newSelectedTags.AddRange(categoryTags);

                                    isDirty |= check.changed;
                                }
                            }
                        }
                        --EditorGUI.indentLevel;

                        if (isDirty || newSelectedTags.Count < oldSelectedTags.Count)
                        {
                            EditorUtilityExtensions.SetSerializedPropertyStringArray(tagsProperty, newSelectedTags.ToArray());
                            editableProfileProperty.FindPropertyRelative("tags.isDirty").boolValue = true;
                        }
                    }

                    if (isUndoRequested)
                    {
                        var tagsProperty = editableProfileProperty.FindPropertyRelative("tags.value");
                        EditorUtilityExtensions.SetSerializedPropertyStringArray(tagsProperty,
                                                                                 profile.tagNames.ToArray());
                        editableProfileProperty.FindPropertyRelative("tags.isDirty").boolValue = false;
                    }
                }
            }
        }