protected virtual void LayoutMetadataKVPField()
        {
            SerializedProperty mkvpsProp = editableProfileProperty.FindPropertyRelative("metadataKVPs.value");

            EditorGUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.BeginVertical();
            EditorGUILayoutExtensions.CustomLayoutArrayPropertyField(mkvpsProp,
                                                                     "Metadata KVPs",
                                                                     ref isKVPsExpanded,
                                                                     LayoutMetadataKVPEntryField);
            EditorGUILayout.EndVertical();

            bool isDirty         = EditorGUI.EndChangeCheck();
            bool isUndoRequested = EditorGUILayoutExtensions.UndoButton(isUndoEnabled);

            EditorGUILayout.EndHorizontal();

            editableProfileProperty.FindPropertyRelative("metadataKVPs.isDirty").boolValue |= isDirty;

            if (isUndoRequested)
            {
                mkvpsProp.arraySize = profile.metadataKVPs.Length;
                for (int i = 0; i < profile.metadataKVPs.Length; ++i)
                {
                    mkvpsProp.GetArrayElementAtIndex(i).FindPropertyRelative("key").stringValue   = profile.metadataKVPs[i].key;
                    mkvpsProp.GetArrayElementAtIndex(i).FindPropertyRelative("value").stringValue = profile.metadataKVPs[i].value;
                }

                editableProfileProperty.FindPropertyRelative("metadataKVPs.isDirty").boolValue = false;
            }
        }
Esempio n. 2
0
        // ------[ GUI ]------
        public void OnGUI()
        {
            isRepaintRequired = false;

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Media");
            GUILayout.FlexibleSpace();
            using (new EditorGUI.DisabledScope(profile == null))
            {
                if (EditorGUILayoutExtensions.UndoButton())
                {
                    ResetModMedia();
                }
            }
            EditorGUILayout.EndHorizontal();

            using (new EditorGUI.IndentLevelScope())
            {
                // - YouTube -
                EditorGUI.BeginChangeCheck();
                EditorGUILayoutExtensions.ArrayPropertyField(youtubeURLsProp.FindPropertyRelative("value"),
                                                             "YouTube Links", ref isYouTubeExpanded);
                youtubeURLsProp.FindPropertyRelative("isDirty").boolValue |= EditorGUI.EndChangeCheck();
                // - SketchFab -
                EditorGUI.BeginChangeCheck();
                EditorGUILayoutExtensions.ArrayPropertyField(sketchfabURLsProp.FindPropertyRelative("value"),
                                                             "SketchFab Links", ref isSketchFabExpanded);
                sketchfabURLsProp.FindPropertyRelative("isDirty").boolValue |= EditorGUI.EndChangeCheck();
                // - Gallery Images -
                EditorGUI.BeginChangeCheck();
                EditorGUILayoutExtensions.CustomLayoutArrayPropertyField(galleryImagesProp.FindPropertyRelative("value"),
                                                                         "Gallery Images Links",
                                                                         ref isImagesExpanded,
                                                                         LayoutGalleryImageProperty);
                galleryImagesProp.FindPropertyRelative("isDirty").boolValue |= EditorGUI.EndChangeCheck();
            }
        }