private IEnumerator AndroidExpoterdHandler() { var settings = UMPSettings.GetSettings(); foreach (var exportedPath in settings.AndroidExportedPaths) { var tempFilePath = System.IO.Path.Combine(Application.temporaryCachePath, exportedPath); var saPath = "Assets" + System.IO.Path.AltDirectorySeparatorChar + "StreamingAssets" + System.IO.Path.AltDirectorySeparatorChar; var localFilePath = exportedPath.Replace(saPath, ""); if (File.Exists(tempFilePath)) { _cachedVideoPaths.Add(localFilePath, tempFilePath); continue; } var www = new WWW(System.IO.Path.Combine(Application.streamingAssetsPath, localFilePath)); yield return(www); if (string.IsNullOrEmpty(www.error)) { var tempFile = new FileInfo(tempFilePath); tempFile.Directory.Create(); File.WriteAllBytes(tempFile.FullName, www.bytes); _cachedVideoPaths.Add(localFilePath, tempFilePath); } else { Debug.LogError("Can't create temp file from asset folder: " + www.error); } www.Dispose(); } _isExportCompleted = true; }
public static void OnPostprocessBuild(BuildTarget buildTarget, string path) { var settings = UMPSettings.GetSettings(); switch (buildTarget) { case BuildTarget.StandaloneWindows: BuildWindowsPlayer32(path, settings); break; case BuildTarget.StandaloneWindows64: BuildWindowsPlayer64(path, settings); break; case BuildTarget.StandaloneLinux: BuildLinuxPlayer32(path, settings); break; case BuildTarget.StandaloneLinux64: BuildLinuxPlayer64(path, settings); break; case BuildTarget.StandaloneLinuxUniversal: BuildLinuxPlayerUniversal(path, settings); break; case BuildTarget.iOS: BuildForiOS(path, settings); break; } if (buildTarget == (BuildTarget)2 || buildTarget == (BuildTarget)27) { BuildMacPlayer64(path, buildTarget, settings); } }
public override void OnInspectorGUI() { serializedObject.Update(); var umpEditor = (UniversalMediaPlayer)target; var umpSettings = UMPSettings.GetSettings(); EditorGUI.BeginChangeCheck(); _cachedFontStyle = EditorStyles.label.fontStyle; _cachedTextColor = EditorStyles.textField.normal.textColor; _cachedLabelWordWrap = EditorStyles.label.wordWrap; #region Rendering Field EditorGUILayout.Space(); EditorGUILayout.PropertyField(_renderingObjectsProp, new GUIContent("Rendering GameObjects:"), true); #endregion #region Path Field EditorGUILayout.Space(); EditorStyles.label.fontStyle = FontStyle.Bold; EditorGUILayout.LabelField("Path to video file:"); EditorStyles.label.fontStyle = _cachedFontStyle; EditorStyles.textField.wordWrap = true; _pathProp.stringValue = EditorGUILayout.TextField(_pathProp.stringValue, GUILayout.Height(30)); EditorStyles.textField.wordWrap = false; #endregion #region Additional Fields EditorGUILayout.Space(); EditorStyles.label.fontStyle = FontStyle.Bold; EditorGUILayout.LabelField("Additional properties:"); EditorStyles.label.fontStyle = _cachedFontStyle; GUILayout.BeginVertical("Box"); GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("AutoPlay:", GUILayout.MinWidth(60)); _autoPlayProp.boolValue = EditorGUILayout.Toggle(_autoPlayProp.boolValue, EditorStyles.radioButton); if (!_loopSmoothProp.boolValue) { EditorGUILayout.LabelField("Loop:", GUILayout.MinWidth(36)); } else { EditorGUILayout.LabelField("Loop(smooth):", GUILayout.MinWidth(90)); } _loopProp.boolValue = EditorGUILayout.Toggle(_loopProp.boolValue, EditorStyles.radioButton, GUILayout.MaxWidth(20)); EditorGUI.BeginDisabledGroup(Application.isPlaying); _loopSmoothProp.boolValue = EditorGUILayout.Toggle(_loopSmoothProp.boolValue, EditorStyles.radioButton); EditorGUI.EndDisabledGroup(); EditorGUILayout.LabelField("Mute:", GUILayout.MinWidth(36)); _muteProp.boolValue = EditorGUILayout.Toggle(_muteProp.boolValue, EditorStyles.radioButton); GUILayout.EndHorizontal(); if (_toggleButton == null) { _toggleButton = new GUIStyle(EditorStyles.miniButtonMid); _toggleButton.normal.background = EditorStyles.miniButton.active.background; } if (GUILayout.Button("Advanced options", _useAdvancedProp.boolValue ? _toggleButton : EditorStyles.miniButtonMid)) { _useAdvancedProp.boolValue = !_useAdvancedProp.boolValue; _availablePlatforms = UMPSettings.InstalledPlayerPlatforms(UMPSettings.Desktop | UMPSettings.Mobile); } if (_useAdvancedProp.boolValue) { EditorGUI.BeginDisabledGroup(Application.isPlaying); _cachedLabelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 170; _useFixedSizeProp.boolValue = EditorGUILayout.Toggle("Use fixed video size:", _useFixedSizeProp.boolValue); if (_useFixedSizeProp.boolValue) { _fixedVideoWidthProp.intValue = EditorGUILayout.IntField(new GUIContent("Width: ", "Fixed video width."), _fixedVideoWidthProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Fixed video width.")); _fixedVideoWidthProp.intValue = Mathf.Clamp(_fixedVideoWidthProp.intValue, 1, 7680); _fixedVideoHeightProp.intValue = EditorGUILayout.IntField(new GUIContent("Height: ", "Fixed video height."), _fixedVideoHeightProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Fixed video height.")); _fixedVideoHeightProp.intValue = Mathf.Clamp(_fixedVideoHeightProp.intValue, 1, 7680); } else { _fixedVideoWidthProp.intValue = 0; _fixedVideoHeightProp.intValue = 0; } EditorGUI.EndDisabledGroup(); EditorGUILayout.Space(); if (_availablePlatforms == null || _availablePlatforms.Length <= 0) { _availablePlatforms = UMPSettings.InstalledPlayerPlatforms(UMPSettings.Desktop | UMPSettings.Mobile); } if (_availablePlatforms.Length <= 0) { var warningLabel = new GUIStyle(EditorStyles.textArea); warningLabel.fontStyle = FontStyle.Bold; EditorGUILayout.LabelField("Can't find 'UniversalMediaPlayer' asset folder, please check your Unity UMP preferences.", warningLabel); EditorStyles.label.normal.textColor = _cachedTextColor; EditorStyles.label.fontStyle = _cachedFontStyle; if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } return; } _chosenPlatformProp.intValue = GUILayout.SelectionGrid(_chosenPlatformProp.intValue, _availablePlatforms, _availablePlatforms.Length, EditorStyles.miniButton); _chosenPlatformProp.intValue = Mathf.Clamp(_chosenPlatformProp.intValue, 0, _availablePlatforms.Length - 1); #region Desktop Options if (_availablePlatforms[_chosenPlatformProp.intValue] == UMPSettings.DESKTOP_CATEGORY_NAME) { EditorGUI.BeginDisabledGroup(Application.isPlaying); #region Audio Option GUILayout.BeginHorizontal(); GUILayout.Space(13); EditorGUILayout.PropertyField(_desktopAudioOutputsProp, new GUIContent("Audio Outputs:"), true); GUILayout.EndHorizontal(); EditorGUILayout.Space(); #endregion #region Decoding Options EditorGUILayout.PropertyField(_desktopHardwareDecodingProp, new GUIContent("Hardware decoding: ", "This allows hardware decoding when available."), false); if (_desktopHardwareDecodingProp.intValue == (int)PlayerOptions.States.Default) { var hardwareDecodingName = "DirectX Video Acceleration (DXVA) 2.0"; if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Mac) { hardwareDecodingName = "Video Decode Acceleration Framework (VDA)"; } if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Linux) { hardwareDecodingName = "VA-API video decoder via DRM"; } GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", hardwareDecodingName)); } if (_desktopHardwareDecodingProp.intValue == (int)PlayerOptions.States.Enable) { GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Automatic")); } EditorGUILayout.Space(); #endregion #region Flip Options _desktopFlipVerticallyProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Flip vertically: ", "Flip video frame vertically when we get it from native library (CPU usage cost)."), _desktopFlipVerticallyProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Flip video frame vertically when we get it from native library (CPU usage cost).")); #endregion #region Buffer Options _desktopVideoBufferSizeProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Video Buffer Size: ", "To gain video resolution will be used special video buffer instead of size of video gotted directly from library."), _desktopVideoBufferSizeProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "To gain video resolution will be used special video buffer instead of size of video gotted directly from library.")); #endregion #region Dublicate Options _desktopOutputToFileProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Data to a file: ", "Duplicate the output stream and redirect it to a file (output file must have '.mp4' video file format)."), _desktopOutputToFileProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Duplicate the output stream and redirect it to a file (output file must have '.mp4' video file format).")); if (_desktopOutputToFileProp.boolValue) { _desktopDisplayOutputProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Display source video: ", "Display source video when duplicate data to a file."), _desktopDisplayOutputProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Display source video when duplicate data to a file.")); _desktopOutputFilePathProp.stringValue = EditorGUILayout.TextField(new GUIContent("Path to file: ", "Full path to a file where output data will be stored (example: 'C:\\Path\\To\\File\\Name.mp4')."), _desktopOutputFilePathProp.stringValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Full path to a file where output data will be stored (example: 'C:\\Path\\To\\File\\Name.mp4').")); } EditorGUILayout.Space(); #endregion #region RTP/RTSP/SDP Options _desktopRtspOverTcpProp.boolValue = EditorGUILayout.Toggle(new GUIContent("RTP over RTSP (TCP): ", "Use RTP over RTSP (TCP) (HTTP default)."), _desktopRtspOverTcpProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use RTP over RTSP (TCP) (HTTP default).")); #endregion EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(umpEditor.IsReady); #region Caching Options _desktopFileCachingProp.intValue = EditorGUILayout.IntField(new GUIContent("File caching (ms): ", "Caching value for local files, in milliseconds."), _desktopFileCachingProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for local files, in milliseconds.")); _desktopFileCachingProp.intValue = Mathf.Clamp(_desktopFileCachingProp.intValue, 0, 60000); _desktopLiveCachingProp.intValue = EditorGUILayout.IntField(new GUIContent("Live capture caching (ms): ", "Caching value for cameras and microphones, in milliseconds."), _desktopLiveCachingProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for cameras and microphones, in milliseconds.")); _desktopLiveCachingProp.intValue = Mathf.Clamp(_desktopLiveCachingProp.intValue, 0, 60000); _desktopDiskCachingProp.intValue = EditorGUILayout.IntField(new GUIContent("Disc caching (ms): ", "Caching value for optical media, in milliseconds."), _desktopDiskCachingProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for optical media, in milliseconds.")); _desktopDiskCachingProp.intValue = Mathf.Clamp(_desktopDiskCachingProp.intValue, 0, 60000); _desktopNetworkCachingProp.intValue = EditorGUILayout.IntField(new GUIContent("Network caching (ms): ", "Caching value for network resources, in milliseconds."), _desktopNetworkCachingProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for network resources, in milliseconds.")); _desktopNetworkCachingProp.intValue = Mathf.Clamp(_desktopNetworkCachingProp.intValue, 0, 60000); #endregion EditorGUI.EndDisabledGroup(); } #endregion #region WebGL Options if (_availablePlatforms[_chosenPlatformProp.intValue] == UMPSettings.Platforms.WebGL.ToString()) { var warningLabel = new GUIStyle(EditorStyles.textArea); warningLabel.fontStyle = FontStyle.Bold; EditorGUILayout.LabelField("Doesn't support any additional options for current platform in this version.", warningLabel); } #endregion EditorGUI.BeginDisabledGroup(Application.isPlaying); #region Android Options if (_availablePlatforms[_chosenPlatformProp.intValue] == UMPSettings.Platforms.Android.ToString()) { #region Player Type Options EditorGUILayout.Space(); var playersNames = new List <string>(); var playerValues = (int[])Enum.GetValues(typeof(PlayerOptionsAndroid.PlayerTypes)); var playerEnum = (PlayerOptionsAndroid.PlayerTypes)_androidPlayerTypeProp.intValue; var choosedPlayer = -1; for (int i = 0; i < playerValues.Length; i++) { var playerType = (PlayerOptionsAndroid.PlayerTypes)playerValues[i]; if ((umpSettings.PlayersAndroid & playerType) == playerType) { playersNames.Add(playerType.ToString()); if (playerEnum == playerType) { choosedPlayer = playersNames.Count - 1; } } } if (choosedPlayer < 0) { choosedPlayer = 0; } GUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("Player Type:", "Choose player type for current instance"), GUILayout.Width(80)); EditorGUILayout.Space(); choosedPlayer = GUILayout.SelectionGrid(choosedPlayer, playersNames.ToArray(), playersNames.Count, EditorStyles.miniButton, GUILayout.Width(playersNames.Count * 60)); GUILayout.EndHorizontal(); _androidPlayerTypeProp.intValue = (int)Enum.Parse(typeof(PlayerOptionsAndroid.PlayerTypes), playersNames[choosedPlayer]); _androidPlayerTypeProp.serializedObject.ApplyModifiedProperties(); EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); #endregion if (_androidPlayerTypeProp.intValue == (int)PlayerOptionsAndroid.PlayerTypes.LibVLC) { #region Hardware Acceleration Options EditorGUILayout.PropertyField(_androidHardwareAccelerationProp, new GUIContent("Hardware Acceleration: ", "This allows hardware acceleration when available:\n* Disabled: better stability.\n* Decoding: may improve performance.\n* Full: may improve performance further."), false); if (_androidHardwareAccelerationProp.intValue == (int)PlayerOptionsAndroid.DecodingStates.Disabled) { GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Disabled: better stability.")); } if (_androidHardwareAccelerationProp.intValue == (int)PlayerOptionsAndroid.DecodingStates.DecodingAcceleration) { GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Decoding: may improve performance.")); } if (_androidHardwareAccelerationProp.intValue == (int)PlayerOptionsAndroid.DecodingStates.FullAcceleration) { GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Full: may improve performance further.")); } EditorGUILayout.Space(); #endregion #region OpenGL Decoding Options EditorGUILayout.PropertyField(_androidOpenGLDecodingProp, new GUIContent("OpenGL Decoding: ", "OpenGL ES2 is used for software decoding and hardware decoding when needed (360° videos), but can affect on correct video rendering."), false); if (_androidOpenGLDecodingProp.intValue == (int)PlayerOptions.States.Default) { GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Automatic.")); } if (_androidOpenGLDecodingProp.intValue == (int)PlayerOptions.States.Disable) { GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Force Off.")); } if (_androidOpenGLDecodingProp.intValue == (int)PlayerOptions.States.Enable) { GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Force On.")); } EditorGUILayout.Space(); #endregion #region Video Chroma Options EditorGUILayout.PropertyField(_androidVideoChromaProp, new GUIContent("Force video chroma: ", "* RGB 32-bit: default chroma\n* RGB 16-bit: better performance but lower quality\n* YUV: best performance but does not work on all devices. Android 2.3 and later only."), false); if (_androidOpenGLDecodingProp.intValue == (int)PlayerOptionsAndroid.ChromaTypes.RGB32Bit) { GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "RGB 32-bit: default chroma.")); } if (_androidOpenGLDecodingProp.intValue == (int)PlayerOptionsAndroid.ChromaTypes.RGB16Bit) { GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "RGB 16-bit: better performance but lower quality.")); } if (_androidOpenGLDecodingProp.intValue == (int)PlayerOptionsAndroid.ChromaTypes.YUV) { GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "YUV: best performance but does not work on all devices. Android 2.3 and later only.")); } EditorGUILayout.Space(); #endregion #region Background Options _androidPlayInBackgroundProb.boolValue = EditorGUILayout.Toggle(new GUIContent("Play in background: ", "Continue play video when application in background."), _androidPlayInBackgroundProb.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Continue play video when application in background.")); #endregion #region RTP/RTSP/SDP Options _androidRtspOverTcpProp.boolValue = EditorGUILayout.Toggle(new GUIContent("RTP over RTSP (TCP): ", "Use RTP over RTSP (TCP) (HTTP default)."), _androidRtspOverTcpProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use RTP over RTSP (TCP) (HTTP default).")); #endregion #region Caching Options _androidNetworkCachingProp.intValue = EditorGUILayout.IntField(new GUIContent("Network caching (ms): ", "The amount of time to buffer network media (in ms). Does not work with hardware decoding. Leave '0' to reset."), _androidNetworkCachingProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "The amount of time to buffer network media (in ms). Does not work with hardware decoding. Leave '0' to reset.")); _androidNetworkCachingProp.intValue = Mathf.Clamp(_androidNetworkCachingProp.intValue, 0, 60000); #endregion } else { var warningLabel = new GUIStyle(EditorStyles.textArea); warningLabel.fontStyle = FontStyle.Bold; EditorGUILayout.LabelField("Doesn't support any additional options for '" + ((PlayerOptionsAndroid.PlayerTypes)_androidPlayerTypeProp.intValue).ToString() + "' player in this version.", warningLabel); } } #endregion EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(Application.isPlaying); #region IPhone Options if (_availablePlatforms[_chosenPlatformProp.intValue] == UMPSettings.Platforms.iOS.ToString()) { #region Player Type Options EditorGUILayout.Space(); var playersNames = new List <string>(); var playerValues = (int[])Enum.GetValues(typeof(PlayerOptionsIPhone.PlayerTypes)); var playerEnum = (PlayerOptionsIPhone.PlayerTypes)_iphonePlayerTypeProp.intValue; var choosedPlayer = -1; for (int i = 0; i < playerValues.Length; i++) { var playerType = (PlayerOptionsIPhone.PlayerTypes)playerValues[i]; if ((umpSettings.PlayersIPhone & playerType) == playerType) { playersNames.Add(playerType.ToString()); if (playerEnum == playerType) { choosedPlayer = playersNames.Count - 1; } } } if (choosedPlayer < 0) { choosedPlayer = 0; } GUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("Player Type:", "Choose player type for current instance"), GUILayout.Width(80)); EditorGUILayout.Space(); choosedPlayer = GUILayout.SelectionGrid(choosedPlayer, playersNames.ToArray(), playersNames.Count, EditorStyles.miniButton, GUILayout.Width(playersNames.Count * 60)); GUILayout.EndHorizontal(); _iphonePlayerTypeProp.intValue = (int)Enum.Parse(typeof(PlayerOptionsIPhone.PlayerTypes), playersNames[choosedPlayer]); _iphonePlayerTypeProp.serializedObject.ApplyModifiedProperties(); EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); #endregion if (_iphonePlayerTypeProp.intValue == (int)PlayerOptionsIPhone.PlayerTypes.FFmpeg) { #region VideoToolbox Options _iphoneVideoToolboxProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Hardware decoding: ", "This allows hardware decoding when available (enable VideoToolbox decoding)."), _iphoneVideoToolboxProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "This allows hardware decoding when available (enable VideoToolbox decoding).")); if (_iphoneVideoToolboxProp.boolValue) { _iphoneVideoToolboxMaxFrameWidthProp.intValue = EditorGUILayout.IntField(new GUIContent("Max width of output frame: ", "Max possible video resolution for hardware decoding."), _iphoneVideoToolboxMaxFrameWidthProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Max possible video resolution for hardware decoding.")); _iphoneVideoToolboxMaxFrameWidthProp.intValue = Mathf.Clamp(_iphoneVideoToolboxMaxFrameWidthProp.intValue, 0, 32768); _iphoneVideoToolboxAsyncProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Async decompression: ", "Use asynchronous decompression for hardware frame decoding."), _iphoneVideoToolboxAsyncProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use asynchronous decompression for hardware frame decoding.")); if (_iphoneVideoToolboxAsyncProp.boolValue) { _iphoneVideoToolboxWaitAsyncProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Wait for asynchronous frames: ", "Wait when frames is ready."), _iphoneVideoToolboxWaitAsyncProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Wait when frames is ready.")); } } EditorGUILayout.Space(); #endregion #region Background Options _iphonePlayInBackgroundProb.boolValue = EditorGUILayout.Toggle(new GUIContent("Play in background: ", "Continue play video when application in background."), _iphonePlayInBackgroundProb.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Continue play video when application in background.")); #endregion #region RTP/RTSP/SDP Options _iphoneRtspOverTcpProp.boolValue = EditorGUILayout.Toggle(new GUIContent("RTP over RTSP (TCP): ", "Use RTP over RTSP (TCP) (HTTP default)."), _iphoneRtspOverTcpProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use RTP over RTSP (TCP) (HTTP default).")); #endregion #region Buffer Options _iphonePacketBufferingProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Packet buffering: ", "Pause output until enough packets have been read after stalling."), _iphonePacketBufferingProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Pause output until enough packets have been read after stalling.")); _iphoneMaxBufferSizeProp.intValue = EditorGUILayout.IntField(new GUIContent("Max buffer size: ", "Max buffer size should be pre-read (in bytes)."), _iphoneMaxBufferSizeProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Max buffer size should be pre-read.")); _iphoneMaxBufferSizeProp.intValue = Mathf.Clamp(_iphoneMaxBufferSizeProp.intValue, 0, 15 * 1024 * 1024); _iphoneMinFramesProp.intValue = EditorGUILayout.IntField(new GUIContent("Min frames: ", "Minimal frames to stop pre-reading."), _iphoneMinFramesProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Minimal frames to stop pre-reading.")); _iphoneMinFramesProp.intValue = Mathf.Clamp(_iphoneMinFramesProp.intValue, 5, 50000); _iphoneInfbufProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Infbuf: ", "Don't limit the input buffer size (useful with realtime streams)."), _iphoneInfbufProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Don't limit the input buffer size (useful with realtime streams).")); EditorGUILayout.Space(); #endregion #region Frame Options _iphoneFramedropProp.intValue = EditorGUILayout.IntField(new GUIContent("Framedrop: ", "Drop frames when cpu is too slow."), _iphoneFramedropProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Drop frames when cpu is too slow.")); _iphoneFramedropProp.intValue = Mathf.Clamp(_iphoneFramedropProp.intValue, -1, 120); _iphoneMaxFpsProp.intValue = EditorGUILayout.IntField(new GUIContent("Max fps: ", "Drop frames in video whose fps is greater than max-fps."), _iphoneMaxFpsProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Drop frames in video whose fps is greater than max-fps.")); _iphoneMaxFpsProp.intValue = Mathf.Clamp(_iphoneMaxFpsProp.intValue, -1, 120); #endregion } else if (_iphonePlayerTypeProp.intValue == (int)PlayerOptionsIPhone.PlayerTypes.Native) { #region Flip Options _iphoneFlipVerticallyProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Flip vertically: ", "Flip video frame vertically when we get it from native library (CPU usage cost)."), _iphoneFlipVerticallyProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Flip video frame vertically when we get it from native library (CPU usage cost).")); #endregion } else { var warningLabel = new GUIStyle(EditorStyles.textArea); warningLabel.fontStyle = FontStyle.Bold; EditorGUILayout.LabelField("Doesn't support any additional options for '" + ((PlayerOptionsAndroid.PlayerTypes)_iphonePlayerTypeProp.intValue).ToString() + "' player in this version.", warningLabel); } } #endregion EditorGUI.EndDisabledGroup(); EditorGUIUtility.labelWidth = _cachedLabelWidth; } else { _desktopFileCachingProp.intValue = PlayerOptions.DEFAULT_CACHING_VALUE; _desktopLiveCachingProp.intValue = PlayerOptions.DEFAULT_CACHING_VALUE; _desktopDiskCachingProp.intValue = PlayerOptions.DEFAULT_CACHING_VALUE; _desktopNetworkCachingProp.intValue = PlayerOptions.DEFAULT_CACHING_VALUE; _fixedVideoWidthProp.intValue = -1; _fixedVideoHeightProp.intValue = -1; } if (UMPSettings.GetSettings().UseExternalLibs) { if (_externalPath.Equals(string.Empty)) { _externalPath = UMPSettings.RuntimePlatformLibraryPath(true); } if (_externalPath != string.Empty) { var wrapTextStyle = EditorStyles.textArea; wrapTextStyle.wordWrap = true; EditorGUILayout.LabelField("Path to external/installed libraries: '" + _externalPath + "'", wrapTextStyle); } } else { _externalPath = string.Empty; } GUILayout.EndVertical(); #endregion #region Player Fields EditorGUILayout.Space(); EditorStyles.label.fontStyle = FontStyle.Bold; EditorGUILayout.LabelField("Player properties:"); EditorStyles.label.fontStyle = _cachedFontStyle; GUILayout.BeginHorizontal(); GUILayout.BeginVertical("Box"); GUILayout.BeginHorizontal(); var centeredStyle = GUI.skin.GetStyle("Label"); centeredStyle.alignment = TextAnchor.MiddleCenter; EditorGUILayout.LabelField("Volume", centeredStyle, GUILayout.MinWidth(80)); if (GUILayout.Button("x", EditorStyles.miniButton)) { _volumeProp.intValue = 50; } GUILayout.EndHorizontal(); _volumeProp.intValue = EditorGUILayout.IntSlider(_volumeProp.intValue, 0, 100); GUILayout.EndVertical(); GUILayout.BeginVertical("Box"); GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Play rate", centeredStyle, GUILayout.MinWidth(80)); if (GUILayout.Button("x", EditorStyles.miniButton)) { _playRateProp.floatValue = 1f; } GUILayout.EndHorizontal(); _playRateProp.floatValue = EditorGUILayout.Slider(_playRateProp.floatValue, 0.5f, 5f); GUILayout.EndVertical(); GUILayout.EndHorizontal(); EditorGUI.BeginDisabledGroup(!umpEditor.IsReady); EditorGUILayout.Space(); GUILayout.BeginVertical("Box"); EditorGUILayout.LabelField("Position", centeredStyle, GUILayout.MinWidth(100)); _positionProp.floatValue = EditorGUILayout.Slider(_positionProp.floatValue, 0f, 1f); GUILayout.EndVertical(); EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(!Application.isPlaying || !umpEditor.isActiveAndEnabled || umpEditor.IsParsing); GUILayout.BeginHorizontal("Box"); if (GUILayout.Button("LOAD", GUILayout.MinWidth(40))) { umpEditor.Prepare(); } if (GUILayout.Button("PLAY", GUILayout.MinWidth(40))) { umpEditor.Play(); } if (GUILayout.Button("PAUSE", GUILayout.MinWidth(40))) { umpEditor.Pause(); } if (GUILayout.Button("STOP", GUILayout.MinWidth(40))) { umpEditor.Stop(); } if (GUILayout.Button("SHOT", GUILayout.MinWidth(40))) { umpEditor.Snapshot(Application.persistentDataPath); } GUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); #endregion #region Events & Logging Fields EditorGUILayout.Space(); EditorStyles.label.fontStyle = FontStyle.Bold; EditorGUILayout.LabelField("Events & Logging:"); EditorStyles.label.fontStyle = _cachedFontStyle; GUILayout.BeginVertical("Box"); EditorGUI.BeginDisabledGroup(Application.isPlaying); EditorGUILayout.PropertyField(_logDetailProp, GUILayout.MinWidth(50)); EditorGUI.EndDisabledGroup(); GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Last msg: ", GUILayout.MinWidth(70)); EditorStyles.label.normal.textColor = Color.black; EditorStyles.label.fontStyle = FontStyle.Italic; EditorStyles.label.wordWrap = true; EditorGUILayout.LabelField(_lastEventMsgProp.stringValue, GUILayout.MaxWidth(100)); EditorStyles.label.normal.textColor = _cachedTextColor; EditorStyles.label.fontStyle = _cachedFontStyle; EditorStyles.label.wordWrap = _cachedLabelWordWrap; GUILayout.EndHorizontal(); GUILayout.EndVertical(); _showEventsListeners = EditorGUILayout.Foldout(_showEventsListeners, "Event Listeners"); if (_showEventsListeners) { EditorGUILayout.PropertyField(_pathPreparedEventProp, new GUIContent("Path Prepared"), true, GUILayout.MinWidth(50)); EditorGUILayout.PropertyField(_openingEventProp, new GUIContent("Opening"), true, GUILayout.MinWidth(50)); EditorGUILayout.PropertyField(_bufferingEventProp, new GUIContent("Buffering"), true, GUILayout.MinWidth(50)); EditorGUILayout.PropertyField(_imageReadyEventProp, new GUIContent("ImageReady"), true, GUILayout.MinWidth(50)); EditorGUILayout.PropertyField(_preparedEventProp, new GUIContent("Prepared"), true, GUILayout.MinWidth(50)); EditorGUILayout.PropertyField(_playingEventProp, new GUIContent("Playing"), true, GUILayout.MinWidth(50)); EditorGUILayout.PropertyField(_pausedEventProp, new GUIContent("Paused"), true, GUILayout.MinWidth(50)); EditorGUILayout.PropertyField(_stoppedEventProp, new GUIContent("Stopped"), true, GUILayout.MinWidth(50)); EditorGUILayout.PropertyField(_endReachedEventProp, new GUIContent("End Reached"), true, GUILayout.MinWidth(50)); EditorGUILayout.PropertyField(_encounteredErrorEventProp, new GUIContent("Encountered Error"), true, GUILayout.MinWidth(50)); EditorGUILayout.PropertyField(_timeChangedEventProp, new GUIContent("Time Changed"), true, GUILayout.MinWidth(50)); EditorGUILayout.PropertyField(_positionChangedEventProp, new GUIContent("Position Changed"), true, GUILayout.MinWidth(50)); EditorGUILayout.PropertyField(_snapshotTakenEventProp, new GUIContent("Snapshot"), true, GUILayout.MinWidth(50)); } #endregion EditorStyles.label.normal.textColor = _cachedTextColor; EditorStyles.label.fontStyle = _cachedFontStyle; if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } }
private IEnumerator VideoPathPreparing(string path, bool playImmediately, IPathPreparedListener listener) { if (_cachedVideoPaths.ContainsKey(path)) { listener.OnPathPrepared(_cachedVideoPaths[path], playImmediately); yield break; } #if UNITY_EDITOR _lastEventMsg = "Path Preparing"; #endif if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Android) { /// Check if we try to play exported videos and wait when export process will be completed var exptPaths = UMPSettings.GetSettings().AndroidExportedPaths; var filePath = path.Replace("file:///", ""); foreach (var exptPath in exptPaths) { if (exptPath.Contains(filePath)) { while (!_isExportCompleted) { yield return(null); } if (_cachedVideoPaths.ContainsKey(filePath)) { listener.OnPathPrepared(_cachedVideoPaths[filePath], playImmediately); yield break; } break; } } if ((_mediaPlayer.Options as PlayerOptionsAndroid).PlayerType == PlayerOptionsAndroid.PlayerTypes.LibVLC && MediaPlayerHelper.IsAssetsFile(path)) { var tempFilePath = System.IO.Path.Combine(Application.temporaryCachePath, filePath); if (File.Exists(tempFilePath)) { _cachedVideoPaths.Add(path, tempFilePath); listener.OnPathPrepared(tempFilePath, playImmediately); yield break; } var www = new WWW(System.IO.Path.Combine(Application.streamingAssetsPath, filePath)); yield return(www); if (string.IsNullOrEmpty(www.error)) { var tempFile = new FileInfo(tempFilePath); tempFile.Directory.Create(); File.WriteAllBytes(tempFile.FullName, www.bytes); _cachedVideoPaths.Add(path, tempFilePath); path = tempFilePath; } else { Debug.LogError("Can't create temp file from asset folder: " + www.error); } www.Dispose(); } } if (_videoHostingParser.IsVideoHostingUrl(path)) { var videoInfos = _videoHostingParser.GetCachedVideoInfos(path); if (videoInfos == null) { var isError = false; _isParsing = true; _videoHostingParser.ParseVideoInfos(path, (res) => { _isParsing = false; }, (error) => { isError = true; Debug.LogError(error); }); while (_isParsing) { if (isError) { _isParsing = false; yield break; } yield return(null); } videoInfos = _videoHostingParser.GetCachedVideoInfos(path); } var videoInfo = _videoHostingParser.GetBestCompatibleVideo(videoInfos); var directLink = videoInfo.DownloadUrl; if (videoInfo.RequiresDecryption && !videoInfo.IsDecrypted) { var isDecrypted = false; _videoHostingParser.DecryptVideoUrl(videoInfo, (res) => { directLink = videoInfo.DownloadUrl; isDecrypted = true; }); while (!isDecrypted) { yield return(null); } } _cachedVideoPaths.Add(path, directLink); path = directLink; } listener.OnPathPrepared(path, playImmediately); yield return(null); }
#pragma warning restore 0414 private void Awake() { #if UNITY_EDITOR #if UNITY_4 || UNITY_5 || UNITY_2017_1 EditorApplication.playmodeStateChanged += HandleOnPlayModeChanged; #else EditorApplication.playModeStateChanged += HandleOnPlayModeChanged; #endif #endif if (UMPSettings.GetSettings().UseAudioSource&& (_desktopAudioOutputs == null || _desktopAudioOutputs.Length <= 0)) { var audioOutput = gameObject.AddComponent <UMPAudioOutput>(); _desktopAudioOutputs = new UMPAudioOutput[] { audioOutput }; } PlayerOptions options = new PlayerOptions(null); switch (UMPSettings.SupportedPlatform) { case UMPSettings.Platforms.Win: case UMPSettings.Platforms.Mac: case UMPSettings.Platforms.Linux: var standaloneOptions = new PlayerOptionsStandalone(null) { FixedVideoSize = _useFixedSize ? new Vector2(_fixedVideoWidth, _fixedVideoHeight) : Vector2.zero, AudioOutputs = _desktopAudioOutputs, //DirectAudioDevice = "Digital Audio", HardwareDecoding = _desktopHardwareDecoding, FlipVertically = _desktopFlipVertically, VideoBufferSize = _desktopVideoBufferSize, UseTCP = _desktopRtspOverTcp, FileCaching = _desktopFileCaching, LiveCaching = _desktopLiveCaching, DiskCaching = _desktopDiskCaching, NetworkCaching = _desktopNetworkCaching }; if (_desktopOutputToFile) { standaloneOptions.RedirectToFile(_desktopDisplayOutput, _desktopOutputFilePath); } standaloneOptions.SetLogDetail(_logDetail, UnityConsoleLogging); options = standaloneOptions; break; case UMPSettings.Platforms.Android: var androidOptions = new PlayerOptionsAndroid(null) { FixedVideoSize = _useFixedSize ? new Vector2(_fixedVideoWidth, _fixedVideoHeight) : Vector2.zero, PlayerType = _androidPlayerType, HardwareAcceleration = _androidHardwareAcceleration, OpenGLDecoding = _androidOpenGLDecoding, VideoChroma = _androidVideoChroma, PlayInBackground = _androidPlayInBackground, UseTCP = _androidRtspOverTcp, NetworkCaching = _androidNetworkCaching }; options = androidOptions; if (_exportedHandlerEnum == null) { _exportedHandlerEnum = AndroidExpoterdHandler(); StartCoroutine(_exportedHandlerEnum); } break; case UMPSettings.Platforms.iOS: var iphoneOptions = new PlayerOptionsIPhone(null) { FixedVideoSize = _useFixedSize ? new Vector2(_fixedVideoWidth, _fixedVideoHeight) : Vector2.zero, PlayerType = _iphonePlayerType, FlipVertically = _iphoneFlipVertically, VideoToolbox = _iphoneVideoToolbox, VideoToolboxFrameWidth = _iphoneVideoToolboxMaxFrameWidth, VideoToolboxAsync = _iphoneVideoToolboxAsync, VideoToolboxWaitAsync = _iphoneVideoToolboxWaitAsync, PlayInBackground = _iphonePlayInBackground, UseTCP = _iphoneRtspOverTcp, PacketBuffering = _iphonePacketBuffering, MaxBufferSize = _iphoneMaxBufferSize, MinFrames = _iphoneMinFrames, Infbuf = _iphoneInfbuf, Framedrop = _iphoneFramedrop, MaxFps = _iphoneMaxFps }; options = iphoneOptions; break; } _mediaPlayer = new MediaPlayer(this, _renderingObjects, options); // Create scpecial parser to add possibiity of get video link from different video hosting servies (like youtube) _videoHostingParser = new VideoHostingParser(this); // Attach scecial listeners to MediaPlayer instance AddListeners(); // Create additional media player for add smooth loop possibility if (_loopSmooth) { _mediaPlayerLoop = new MediaPlayer(this, _mediaPlayer); _mediaPlayerLoop.VideoOutputObjects = null; _mediaPlayerLoop.EventManager.RemoveAllEvents(); } }
public static void UMPGUI() { var umpSettings = UMPSettings.GetSettings(); var cachedFontStyle = EditorStyles.label.fontStyle; var cachedLabelColor = EditorStyles.label.normal.textColor; var cachedLabelWidth = EditorGUIUtility.labelWidth; var installedMobilePlatforms = UMPSettings.InstalledPlayerPlatforms(UMPSettings.Mobile); if (_buttonStyleToggled == null) { _buttonStyleToggled = new GUIStyle(EditorStyles.miniButton); _buttonStyleToggled.normal.background = _buttonStyleToggled.active.background; } if (playersAndroid == null) { playersAndroid = new bool[Enum.GetNames(typeof(PlayerOptionsAndroid.PlayerTypes)).Length]; for (int i = 0; i < playersAndroid.Length; i++) { var playerType = (PlayerOptionsAndroid.PlayerTypes)((i * 2) + (i == 0 ? 1 : 0)); if ((umpSettings.PlayersAndroid & playerType) == playerType) { playersAndroid[i] = true; } } } if (playersIPhone == null) { playersIPhone = new bool[Enum.GetNames(typeof(PlayerOptionsIPhone.PlayerTypes)).Length]; for (int i = 0; i < playersIPhone.Length; i++) { var playerType = (PlayerOptionsIPhone.PlayerTypes)((i * 2) + (i == 0 ? 1 : 0)); if ((umpSettings.PlayersIPhone & playerType) == playerType) { playersIPhone[i] = true; } } } umpSettings.UseCustomAssetPath = EditorGUILayout.Toggle(new GUIContent("Use custom asset path", "Will be using cusstom asset path to main 'UniversalMediaPlayer' folder (give you possibility to move asset folder in different space in your project)."), umpSettings.UseCustomAssetPath); EditorGUILayout.Space(); EditorGUI.BeginDisabledGroup(!umpSettings.UseCustomAssetPath); EditorStyles.textField.wordWrap = true; umpSettings.AssetPath = EditorGUILayout.TextField(umpSettings.AssetPath, GUILayout.Height(30)); EditorStyles.textField.wordWrap = false; EditorGUI.EndDisabledGroup(); if (!umpSettings.IsValidAssetPath && umpSettings.UseCustomAssetPath) { if (GUILayout.Button("Find asset folder in current project")) { GUI.FocusControl(null); umpSettings.AssetPath = FindAssetFolder("Assets"); } } EditorStyles.label.fontStyle = FontStyle.Italic; if (umpSettings.IsValidAssetPath) { EditorGUILayout.LabelField("Path is correct."); } else { EditorStyles.label.normal.textColor = Color.red; if (!umpSettings.UseCustomAssetPath) { EditorGUILayout.LabelField("Can't find asset folder, try to use custom asset path."); } else { EditorGUILayout.LabelField("Can't find asset folder."); } } EditorStyles.label.normal.textColor = cachedLabelColor; EditorStyles.label.fontStyle = cachedFontStyle; EditorGUILayout.LabelField("Editor/Desktop platforms:", EditorStyles.boldLabel); EditorGUILayout.Space(); umpSettings.UseAudioSource = EditorGUILayout.Toggle(new GUIContent("Use Unity 'Audio Source' component", "Will be using Unity 'Audio Source' component for audio output for all UMP instances (global) by default."), umpSettings.UseAudioSource); EditorGUILayout.Space(); umpSettings.UseExternalLibs = EditorGUILayout.Toggle(new GUIContent("Use installed VLC libraries", "Will be using external/installed VLC player libraries for all UMP instances (global). Path to install VLC directory will be obtained automatically (you can also setup your custom path)."), umpSettings.UseExternalLibs); EditorStyles.label.wordWrap = true; EditorStyles.label.normal.textColor = Color.red; bool useExternal = true; string librariesPath = UMPSettings.RuntimePlatformLibraryPath(false); if (!string.IsNullOrEmpty(librariesPath) && Directory.Exists(librariesPath)) { string[] libraries = Directory.GetFiles(librariesPath); int includes = 0; if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Win) { foreach (var library in libraries) { if (Path.GetFileName(library).Contains("libvlc.dll.meta") || Path.GetFileName(library).Contains("libvlccore.dll.meta") || Path.GetFileName(library).Contains("plugins.meta")) { includes++; } } if (includes >= 3) { useExternal = false; } } if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Mac) { foreach (var library in libraries) { if (Path.GetFileName(library).Contains("libvlc.dylib.meta") || Path.GetFileName(library).Contains("libvlccore.dylib.meta")) { includes++; } } if (includes >= 2) { useExternal = false; } } if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Linux) { foreach (var library in libraries) { if (Path.GetFileName(library).Contains("libvlc.so.meta") || Path.GetFileName(library).Contains("libvlccore.so.meta") || Path.GetFileName(library).Contains("plugins.meta")) { includes++; } } if (includes >= 3) { useExternal = false; } } } if (useExternal) { EditorGUILayout.LabelField("Please correctly import UMP (Win, Mac, Linux) package to use internal VLC libraries."); umpSettings.UseExternalLibs = true; } EditorGUILayout.Space(); if (umpSettings.UseExternalLibs) { string externalLibsPath = UMPSettings.RuntimePlatformLibraryPath(true); if (externalLibsPath.Equals(string.Empty)) { EditorGUILayout.LabelField("Did you install VLC player software correctly? Please make sure that:"); EditorGUILayout.LabelField("1. Your installed VLC player bit application == Unity Editor bit application (VLC player 64-bit == Unity 64-bit Editor);"); EditorGUILayout.LabelField("2. Use last version installer from official site: "); if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Win) { EditorGUILayout.LabelField("Windows platform: "); var link86 = "http://get.videolan.org/vlc/2.2.4/win32/vlc-2.2.4-win32.exe"; EditorStyles.label.normal.textColor = Color.blue; EditorGUILayout.LabelField(link86 + " (Editor x86)"); Rect linkRect86 = GUILayoutUtility.GetLastRect(); if (Event.current.type == EventType.MouseUp && linkRect86.Contains(Event.current.mousePosition)) { Application.OpenURL(link86); } var link64 = "http://get.videolan.org/vlc/2.2.4/win64/vlc-2.2.4-win64.exe"; EditorStyles.label.normal.textColor = Color.blue; EditorGUILayout.LabelField(link64 + " (Editor x64)"); Rect linkRect64 = GUILayoutUtility.GetLastRect(); if (Event.current.type == EventType.MouseUp && linkRect64.Contains(Event.current.mousePosition)) { Application.OpenURL(link64); } } if (UMPSettings.SupportedPlatform == UMPSettings.Platforms.Mac) { EditorGUILayout.LabelField("Mac OS platform: "); var link64 = "http://get.videolan.org/vlc/2.2.4/macosx/vlc-2.2.4.dmg"; EditorStyles.label.normal.textColor = Color.blue; EditorGUILayout.LabelField(link64 + " (Editor x64)"); Rect linkRect64 = GUILayoutUtility.GetLastRect(); if (Event.current.type == EventType.MouseUp && linkRect64.Contains(Event.current.mousePosition)) { Application.OpenURL(link64); } } EditorStyles.label.normal.textColor = Color.red; EditorGUILayout.LabelField("Or you can try to use custom additional path to your VLC libraries."); EditorGUILayout.Space(); } EditorStyles.label.normal.textColor = cachedLabelColor; EditorGUILayout.LabelField(new GUIContent("External/installed VLC libraries path:", "Default path to installed VLC player libraries. Example: '" + @"C:\Program Files\VideoLAN\VLC'.")); GUIStyle pathLabel = EditorStyles.textField; pathLabel.wordWrap = true; EditorGUILayout.LabelField(externalLibsPath, pathLabel); EditorGUILayout.Space(); EditorGUILayout.LabelField(new GUIContent("Additional external/installed VLC libraries path:", "Additional path to installed VLC player libraries. Will be used if path to libraries can't be automatically obtained. Example: '" + @"C:\Program Files\VideoLAN\VLC'.")); GUIStyle additionalLabel = EditorStyles.textField; additionalLabel.wordWrap = true; umpSettings.AdditionalLibsPath = EditorGUILayout.TextField(umpSettings.AdditionalLibsPath); } EditorStyles.label.normal.textColor = cachedLabelColor; if (installedMobilePlatforms.Length > 0) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Mobile platforms:", EditorStyles.boldLabel); EditorGUILayout.Space(); _chosenMobilePlatform = GUILayout.SelectionGrid(_chosenMobilePlatform, installedMobilePlatforms, installedMobilePlatforms.Length, EditorStyles.miniButton); GUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("Player Types:", "Choose player types that will be used in your project")); if (installedMobilePlatforms[_chosenMobilePlatform] == UMPSettings.Platforms.Android.ToString()) { for (int i = 0; i < playersAndroid.Length; i++) { if (GUILayout.Button(Enum.GetName(typeof(PlayerOptionsAndroid.PlayerTypes), (i * 2) + (i == 0 ? 1 : 0)), playersAndroid[i] ? _buttonStyleToggled : EditorStyles.miniButton)) { var playerType = (PlayerOptionsAndroid.PlayerTypes)((i * 2) + (i == 0 ? 1 : 0)); if ((umpSettings.PlayersAndroid & ~playerType) > 0) { playersAndroid[i] = !playersAndroid[i]; umpSettings.PlayersAndroid = playersAndroid[i] ? umpSettings.PlayersAndroid | playerType : umpSettings.PlayersAndroid & ~playerType; LibrariesHandler(UMPSettings.Platforms.Android, umpSettings.PlayersAndroid); } } } } if (installedMobilePlatforms[_chosenMobilePlatform] == UMPSettings.Platforms.iOS.ToString()) { for (int i = 0; i < playersIPhone.Length; i++) { if (GUILayout.Button(Enum.GetName(typeof(PlayerOptionsIPhone.PlayerTypes), (i * 2) + (i == 0 ? 1 : 0)), playersIPhone[i] ? _buttonStyleToggled : EditorStyles.miniButton)) { var playerType = (PlayerOptionsIPhone.PlayerTypes)((i * 2) + (i == 0 ? 1 : 0)); if ((umpSettings.PlayersIPhone & ~playerType) > 0) { playersIPhone[i] = !playersIPhone[i]; umpSettings.PlayersIPhone = playersIPhone[i] ? umpSettings.PlayersIPhone | playerType : umpSettings.PlayersIPhone & ~playerType; LibrariesHandler(UMPSettings.Platforms.iOS, umpSettings.PlayersIPhone); } } } } GUILayout.EndHorizontal(); if (installedMobilePlatforms[_chosenMobilePlatform] == UMPSettings.Platforms.Android.ToString()) { GUILayout.BeginVertical("Box"); _showExportedPaths = EditorGUILayout.Foldout(_showExportedPaths, new GUIContent("Exported Video Paths", "'StreamingAssets' videos (or video parts) that will be copied to special cached destination on device (for possibilities to use playlist: videos that contains many parts)")); if (_showExportedPaths) { scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandHeight(false)); _exportedPathsSize = EditorGUILayout.IntField(new GUIContent("Size", "Amount of exported videos"), umpSettings.AndroidExportedPaths.Length, GUILayout.ExpandWidth(true)); _cachedExportedPaths = new string[_exportedPathsSize]; if (_exportedPathsSize >= 0) { _cachedExportedPaths = new string[_exportedPathsSize]; for (int i = 0; i < umpSettings.AndroidExportedPaths.Length; i++) { if (i < _exportedPathsSize) { _cachedExportedPaths[i] = umpSettings.AndroidExportedPaths[i]; } } } EditorGUIUtility.labelWidth = 60; for (int i = 0; i < _cachedExportedPaths.Length; i++) { _cachedExportedPaths[i] = EditorGUILayout.TextField("Path " + i + ":", _cachedExportedPaths[i]); } EditorGUIUtility.labelWidth = cachedLabelWidth; umpSettings.AndroidExportedPaths = _cachedExportedPaths; EditorGUILayout.EndScrollView(); var evt = Event.current; switch (evt.type) { case EventType.DragUpdated: case EventType.DragPerform: DragAndDrop.visualMode = DragAndDropVisualMode.Copy; if (evt.type == EventType.DragPerform) { DragAndDrop.AcceptDrag(); var filePaths = DragAndDrop.paths; if (filePaths.Length > 0) { var arrayLength = umpSettings.AndroidExportedPaths.Length > filePaths.Length ? umpSettings.AndroidExportedPaths.Length : filePaths.Length; _cachedExportedPaths = new string[arrayLength]; for (int i = 0; i < arrayLength; i++) { if (i < umpSettings.AndroidExportedPaths.Length) { _cachedExportedPaths[i] = umpSettings.AndroidExportedPaths[i]; } if (i < filePaths.Length) { _cachedExportedPaths[i] = filePaths[i]; } } umpSettings.AndroidExportedPaths = _cachedExportedPaths; } } break; } } GUILayout.EndVertical(); } } if (UMPSettings.SaveSettings(umpSettings)) { AssetDatabase.Refresh(); } }