Exemplo n.º 1
0
        private void Callback_Browse(object obj)
        {
            BrowseData         data             = (BrowseData)obj;
            SerializedProperty propFilePath     = data.propPath.FindPropertyRelative("_path");
            SerializedProperty propFilePathType = data.propPath.FindPropertyRelative("_pathType");
            string             startFolder      = EditorHelper.GetBrowsableFolder(propFilePath.stringValue, (MediaPathType)propFilePathType.enumValueIndex);
            string             videoPath        = propFilePath.stringValue;
            string             fullPath         = string.Empty;
            MediaPath          mediaPath        = new MediaPath();

            if (EditorHelper.OpenMediaFileDialog(startFolder, ref mediaPath, ref fullPath, data.extensions))
            {
                // Assign to properties
                propFilePath.stringValue        = mediaPath.Path.Replace("\\", "/");
                propFilePathType.enumValueIndex = (int)mediaPath.PathType;
                if (data.propMediaSource != null)
                {
                    data.propMediaSource.enumValueIndex = (int)MediaSource.Path;
                }

                // Mark as modified
                data.propPath.serializedObject.ApplyModifiedProperties();
                foreach (Object o in data.propPath.serializedObject.targetObjects)
                {
                    EditorUtility.SetDirty(o);
                }

                if (data.autoLoadMedia)
                {
                    MediaPlayer mediaPlayer = (MediaPlayer)data.propPath.serializedObject.targetObject;
                    if (mediaPlayer != null)
                    {
                        mediaPlayer.OpenMedia(mediaPlayer.MediaPath, autoPlay: true);
                    }
                }

                RecentItems.Add(fullPath);
            }
        }
Exemplo n.º 2
0
        private void Callback_Select(object obj)
        {
            RecentMenuItemData data = (RecentMenuItemData)obj;

            // Move it to the top of the list
            RecentItems.Add(data.path);

            // Resolve to relative path
            MediaPath mediaPath = EditorHelper.GetMediaPathFromFullPath(data.path);

            SerializedProperty propMediaPath     = data.propPath.FindPropertyRelative("_path");
            SerializedProperty propMediaPathType = data.propPath.FindPropertyRelative("_pathType");

            // Assign to properties
            propMediaPath.stringValue        = mediaPath.Path.Replace("\\", "/");
            propMediaPathType.enumValueIndex = (int)mediaPath.PathType;
            if (data.propMediaSource != null)
            {
                data.propMediaSource.enumValueIndex = (int)MediaSource.Path;
            }

            // Mark as modified
            data.propPath.serializedObject.ApplyModifiedProperties();
            foreach (Object o in data.propPath.serializedObject.targetObjects)
            {
                EditorUtility.SetDirty(o);
            }

            if (data.autoLoadMedia)
            {
                MediaPlayer mediaPlayer = (MediaPlayer)data.propPath.serializedObject.targetObject;
                if (mediaPlayer != null)
                {
                    mediaPlayer.OpenMedia(mediaPlayer.MediaPath, autoPlay: true);
                }
            }
        }