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 BuildWindowsPlayer32(string path, UMPSettings settings) { string buildPath = Path.GetDirectoryName(path); string dataPath = buildPath + "/" + Path.GetFileNameWithoutExtension(path) + "_Data"; if (!string.IsNullOrEmpty(buildPath)) { if (!settings.UseExternalLibraries) { CopyPlugins(settings.AssetPath + "/Plugins/Win/x86/plugins/", dataPath + "/Plugins/plugins/"); } else { if (File.Exists(dataPath + "/Plugins/" + UMPSettings.LIB_VLC_NAME + ".dll")) { File.Delete(dataPath + "/Plugins/" + UMPSettings.LIB_VLC_NAME + ".dll"); } if (File.Exists(dataPath + "/Plugins/" + UMPSettings.LIB_VLC_CORE_NAME + ".dll")) { File.Delete(dataPath + "/Plugins/" + UMPSettings.LIB_VLC_CORE_NAME + ".dll"); } } } Debug.Log("Standalone Windows (x86) build is completed: " + path); }
public static void BuildMacPlayer64(string path, BuildTarget target, UMPSettings settings) { string buildPath = Path.GetDirectoryName(path); string dataPath = buildPath + "/" + Path.GetFileName(path) + "/Contents"; if (target == (BuildTarget)2) { if (Directory.Exists(dataPath + "/Plugins/x86_64/" + UMPSettings.LIB_VLC_NAME + ".bundle")) { Directory.Move(dataPath + "/Plugins/x86_64/" + UMPSettings.LIB_VLC_NAME + ".bundle", dataPath + "/Plugins/" + UMPSettings.LIB_VLC_NAME + ".bundle"); } if (Directory.Exists(dataPath + "/Plugins/x86_64/" + UMPSettings.ASSET_NAME + ".bundle")) { Directory.Move(dataPath + "/Plugins/x86_64/" + UMPSettings.ASSET_NAME + ".bundle", dataPath + "/Plugins/" + UMPSettings.ASSET_NAME + ".bundle"); } } if (!string.IsNullOrEmpty(buildPath) && settings.UseExternalLibraries) { if (Directory.Exists(dataPath + "/Plugins/" + UMPSettings.LIB_VLC_NAME + ".bundle")) { Directory.Delete(dataPath + "/Plugins/" + UMPSettings.LIB_VLC_NAME + ".bundle", true); } } Debug.Log("Standalone Mac (x86_x64) build is completed: " + dataPath); }
public static void BuildWindowsPlayer64(string path, UMPSettings settings) { string buildPath = Path.GetDirectoryName(path); string dataPath = buildPath + "/" + Path.GetFileNameWithoutExtension(path) + "_Data"; if (!string.IsNullOrEmpty(buildPath)) { if (!settings.UseExternalLibraries) { CopyPlugins(settings.AssetPath + "/Plugins/Win/x86_64/plugins/", dataPath + "/Plugins/plugins/"); string[] files = Directory.GetFiles(dataPath + "/Plugins/x86_64/"); foreach (string str in files) { string file = Path.GetFileName(str); Debug.LogError(file); File.Copy(str, dataPath + "/Plugins/" + file); } Directory.Delete(dataPath + "/Plugins/x86_64/", true); } else { if (File.Exists(dataPath + "/Plugins/" + UMPSettings.LIB_VLC_NAME + ".dll")) { File.Delete(dataPath + "/Plugins/" + UMPSettings.LIB_VLC_NAME + ".dll"); } if (File.Exists(dataPath + "/Plugins/" + UMPSettings.LIB_VLC_CORE_NAME + ".dll")) { File.Delete(dataPath + "/Plugins/" + UMPSettings.LIB_VLC_CORE_NAME + ".dll"); } } } Debug.Log("Standalone Windows (x86_x64) build is completed: " + path); }
public static void BuildLinuxPlayerUniversal(string path, UMPSettings settings) { string buildPath = Path.GetDirectoryName(path); string dataPath = buildPath + "/" + Path.GetFileNameWithoutExtension(path) + "_Data"; string umpLauncherPath = settings.AssetPath + "/Plugins/Linux/UMPInstaller.sh"; string umpRemoverPath = settings.AssetPath + "/Plugins/Linux/UMPRemover.sh"; if (!string.IsNullOrEmpty(buildPath)) { if (!settings.UseExternalLibraries) { string vlcFolderPath32 = dataPath + "/Plugins/x86/vlc"; if (!Directory.Exists(vlcFolderPath32)) { Directory.CreateDirectory(vlcFolderPath32); } string vlcFolderPath64 = dataPath + "/Plugins/x86_64/vlc"; if (!Directory.Exists(vlcFolderPath64)) { Directory.CreateDirectory(vlcFolderPath64); } CopyPlugins(settings.AssetPath + "/Plugins/Linux/x86/plugins/", vlcFolderPath32 + "/plugins/"); CopyPlugins(settings.AssetPath + "/Plugins/Linux/x86_64/plugins/", vlcFolderPath64 + "/plugins/"); } else { if (File.Exists(dataPath + "/Plugins/x86/" + UMPSettings.LIB_VLC_NAME + ".so")) { File.Delete(dataPath + "/Plugins/x86/" + UMPSettings.LIB_VLC_NAME + ".so"); } if (File.Exists(dataPath + "/Plugins/x86/" + UMPSettings.LIB_VLC_CORE_NAME + ".so")) { File.Delete(dataPath + "/Plugins/x86/" + UMPSettings.LIB_VLC_CORE_NAME + ".so"); } if (File.Exists(dataPath + "/Plugins/x86_64/" + UMPSettings.LIB_VLC_NAME + ".so")) { File.Delete(dataPath + "/Plugins/x86_64/" + UMPSettings.LIB_VLC_NAME + ".so"); } if (File.Exists(dataPath + "/Plugins/x86_64/" + UMPSettings.LIB_VLC_CORE_NAME + ".so")) { File.Delete(dataPath + "/Plugins/x86_64/" + UMPSettings.LIB_VLC_CORE_NAME + ".so"); } } CopyShellScript(umpLauncherPath, buildPath); CopyShellScript(umpRemoverPath, buildPath); } Debug.Log("Standalone Linux (Universal) build is completed: " + path); }
public static UMPSettings GetSettings() { TextAsset asset = Resources.Load(SETTINGS_FILE_NAME) as TextAsset; var settings = asset != null?JsonUtility.FromJson <UMPSettings>(asset.text) : null; if (settings == null) { settings = new UMPSettings(); } return(settings); }
private static void LibrariesHandlerAndroid(PlayerOptionsAndroid.PlayerTypes playerType) { var librariesPath = UMPSettings.PlatformLibraryPath(UMPSettings.Platforms.Android, false); List <string> libs = new List <string>(); libs.AddRange(Directory.GetFiles(librariesPath + "libs/armeabi-v7a")); libs.AddRange(Directory.GetFiles(librariesPath + "libs/x86")); var includeLibVLC = (playerType & PlayerOptionsAndroid.PlayerTypes.LibVLC) == PlayerOptionsAndroid.PlayerTypes.LibVLC; foreach (var lib in libs) { if (lib.Contains(".meta") && !lib.Contains("libUniversalMediaPlayer")) { File.SetAttributes(lib, FileAttributes.Normal); string metaData = File.ReadAllText(lib); var match = Regex.Match(metaData, @"Android.*\s*enabled:."); if (match.Success) { metaData = Regex.Replace(metaData, @"Android.*\s*enabled:." + (!includeLibVLC ? 1 : 0), match.Value + (includeLibVLC ? 1 : 0)); File.WriteAllText(lib, metaData); } } } libs.Clear(); var librariesNames = Enum.GetNames(typeof(PlayerOptionsAndroid.PlayerTypes)); libs.AddRange(Directory.GetFiles(librariesPath)); for (int i = 0; i < librariesNames.Length; i++) { var libraryPath = librariesPath + "Player" + librariesNames[i] + " "; var type = (PlayerOptionsAndroid.PlayerTypes)((i * 2) + (i == 0 ? 1 : 0)); var isEnable = (playerType & type) == type; File.SetAttributes(libraryPath, FileAttributes.Normal); string metaData = File.ReadAllText(libraryPath); var match = Regex.Match(metaData, @"Android.*\s*enabled:."); if (match.Success) { metaData = Regex.Replace(metaData, @"Android.*\s*enabled:." + (!isEnable ? 1 : 0), match.Value + (isEnable ? 1 : 0)); File.WriteAllText(libraryPath, metaData); } } libs.Clear(); }
private static void BuildForiOS(string path, UMPSettings settings) { #if UNITY_IPHONE var projPath = Path.Combine(path, "Unity-iPhone.xcodeproj/project.pbxproj"); var pbxProject = new PBXProject(); pbxProject.ReadFromString(File.ReadAllText(projPath)); #if UNITY_2019_3_OR_NEWER var target = pbxProject.GetUnityFrameworkTargetGuid(); #else var target = pbxProject.TargetGuidByName(PBXProject.GetUnityTargetName()); #endif // Activate Background Mode for Audio string plistPath = path + "/Info.plist"; PlistDocument plist = new PlistDocument(); plist.ReadFromString(File.ReadAllText(plistPath)); PlistElementDict rootDict = plist.root; var buildKey = "UIBackgroundModes"; rootDict.CreateArray(buildKey).AddString("audio"); File.WriteAllText(plistPath, plist.WriteToString()); var fileGuid = pbxProject.AddFile("usr/lib/" + "libc++.dylib", "Frameworks/" + "libc++.dylib", PBXSourceTree.Sdk); pbxProject.AddFileToBuild(target, fileGuid); fileGuid = pbxProject.AddFile("usr/lib/" + "libz.dylib", "Frameworks/" + "libz.dylib", PBXSourceTree.Sdk); pbxProject.AddFileToBuild(target, fileGuid); fileGuid = pbxProject.AddFile("usr/lib/" + "libz.tbd", "Frameworks/" + "libz.tbd", PBXSourceTree.Sdk); pbxProject.AddFileToBuild(target, fileGuid); fileGuid = pbxProject.AddFile("usr/lib/" + "libbz2.dylib", "Frameworks/" + "libbz2.dylib", PBXSourceTree.Sdk); pbxProject.AddFileToBuild(target, fileGuid); fileGuid = pbxProject.AddFile("usr/lib/" + "libbz2.tbd", "Frameworks/" + "libbz2.tbd", PBXSourceTree.Sdk); pbxProject.AddFileToBuild(target, fileGuid); if ((settings.PlayersIPhone & PlayerOptionsIPhone.PlayerTypes.Native) == PlayerOptionsIPhone.PlayerTypes.Native) { pbxProject.AddFrameworkToProject(target, "CoreImage.framework", true); } File.WriteAllText(projPath, pbxProject.WriteToString()); #endif }
public static bool SaveSettings(UMPSettings settings) { if (settings != null && settings.IsUpdated) { string settingsText = JsonUtility.ToJson(settings); string settingsFilePath = Path.Combine(settings.AssetPath, SETTINGS_FOLDER_PATH); if (Directory.Exists(settingsFilePath)) { settingsFilePath = Path.Combine(settingsFilePath, SETTINGS_FILE_NAME + ".txt"); File.WriteAllText(settingsFilePath, settingsText); return(true); } return(false); } return(false); }
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); } }
#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(); } }
private static void LibrariesHandler(UMPSettings.Platforms platform, Enum playerType) { if (!(playerType is PlayerOptionsAndroid.PlayerTypes) && !(playerType is PlayerOptionsIPhone.PlayerTypes)) { throw new ArgumentException("Enum must be one of this enumerated type: 'PlayerOptionsAndroid.PlayerTypes' or 'PlayerOptionsAndroid.PlayerTypes'"); } var libPath = UMPSettings.PlatformLibraryPath(platform, false); var playerValues = (int[])Enum.GetValues(playerType.GetType()); var usedLibs = new List <string>(); var flags = string.Empty; var addVLCLibs = false; if (playerType is PlayerOptionsAndroid.PlayerTypes) { addVLCLibs = ((PlayerOptionsAndroid.PlayerTypes)playerType & PlayerOptionsAndroid.PlayerTypes.LibVLC) == PlayerOptionsAndroid.PlayerTypes.LibVLC; } for (int i = 0; i < playerValues.Length; i++) { if (playerType is PlayerOptionsAndroid.PlayerTypes) { var type = (PlayerOptionsAndroid.PlayerTypes)playerValues[i]; if (((PlayerOptionsAndroid.PlayerTypes)playerType & type) == type) { usedLibs.Add(type.ToString()); } } if (playerType is PlayerOptionsIPhone.PlayerTypes) { var type = (PlayerOptionsIPhone.PlayerTypes)playerValues[i]; if (((PlayerOptionsIPhone.PlayerTypes)playerType & type) == type) { usedLibs.Add(type.ToString()); flags += " -D" + type.ToString().ToUpper(); } } } List <string> libs = new List <string>(); libs.AddRange(Directory.GetFiles(libPath)); if (playerType is PlayerOptionsAndroid.PlayerTypes) { libs.AddRange(Directory.GetFiles(libPath + "libs/armeabi-v7a")); libs.AddRange(Directory.GetFiles(libPath + "libs/x86")); } foreach (var lib in libs) { if (lib.Contains(".meta")) { var libName = Path.GetFileNameWithoutExtension(lib); var isEnable = false; foreach (var name in usedLibs) { if (libName.Contains("Player" + name) || libName.Contains("PlayerBase") || libName.Contains("MediaPlayer") || (addVLCLibs && libName.Contains("lib"))) { isEnable = true; } } File.SetAttributes(lib, FileAttributes.Normal); var attributes = File.ReadAllText(lib).Split(' '); var updatedData = string.Empty; var playerAttr = false; for (int i = 0; i < attributes.Length; i++) { foreach (var pluginPlatform in _pluginPlatforms) { if (attributes[i].Contains(pluginPlatform)) { if (pluginPlatform == platform.ToString()) { playerAttr = true; } else { playerAttr = false; } } } if (playerAttr) { //Ignore any compile flags from plugin file if (attributes[i].Contains("-D")) { continue; } if (attributes[i].Contains("enabled")) { attributes[i + 1] = (isEnable ? "1" : "0") + "\n"; } if (attributes[i].Contains("CompileFlags")) { attributes[i] = string.Format("CompileFlags:{0}\n", flags); } } updatedData += string.Format("{0} ", attributes[i]); } File.WriteAllText(lib, updatedData); } } libs.Clear(); }
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(); } }
private UMPPreference() { _umpSettings = UMPSettings.Instance; }
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); }
public override void OnInspectorGUI() { var settings = UMPSettings.Instance; var cachedLabelWidth = EditorGUIUtility.labelWidth; var installedMobilePlatforms = settings.GetInstalledPlatforms(UMPSettings.Mobile); if (_buttonStyleToggled == null) { _buttonStyleToggled = new GUIStyle(EditorStyles.miniButton); _buttonStyleToggled.normal.background = _buttonStyleToggled.active.background; } if (_warningLabel == null) { _warningLabel = new GUIStyle(EditorStyles.label); _warningLabel.padding = new RectOffset(); _warningLabel.margin = new RectOffset(); _warningLabel.wordWrap = true; } 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 ((settings.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 ((settings.PlayersIPhone & playerType) == playerType) { playersIPhone[i] = true; } } } // Display the asset path #region Asset Path EditorGUILayout.BeginVertical(GUI.skin.box); EditorGUILayout.LabelField("Asset Path", EditorStyles.boldLabel); EditorGUI.BeginDisabledGroup(true); ShowMessageBox(MessageType.None, _assetPathProp.stringValue); EditorGUI.EndDisabledGroup(); if (settings.IsValidAssetPath) { ShowMessageBox(MessageType.Info, "Path is correct"); } else { ShowMessageBox(MessageType.Error, "Can't find asset folder"); } GUI.color = Color.green; if (!settings.IsValidAssetPath) { if (GUILayout.Button("Find Asset Folder")) { GUI.FocusControl(null); _assetPathProp.stringValue = FindAssetFolder("Assets"); } } GUI.color = Color.white; EditorGUILayout.EndVertical(); #endregion // Display the Editor/Desktop options #region Editor/Desktop EditorGUILayout.BeginVertical(GUI.skin.box); EditorGUILayout.LabelField("Editor/Desktop", EditorStyles.boldLabel); EditorGUILayout.PropertyField(_useAudioSourceProp, new GUIContent("Use 'Audio Source'", "Will be using Unity 'Audio Source' component for audio output for all UMP instances (global) by default (supported only on desktop platforms)")); /*EditorGUILayout.BeginHorizontal(); * GUILayout.Label(new GUIContent("Use 'Audio Source' component", "Will be using Unity 'Audio Source' component for audio output for all UMP instances (global) by default.")); * _useAudioSourceProp.boolValue = EditorGUILayout.Toggle(_useAudioSourceProp.boolValue); * EditorGUILayout.EndHorizontal();*/ var useInstalled = !UMPSettings.ContainsLibVLC(settings.GetLibrariesPath(UMPSettings.RuntimePlatform, false)); if (useInstalled) { ShowMessageBox(MessageType.Warning, "Can't find internal LibVLC libraries in current project, so will be used installed VLC player software by default. To have possibility to use internal libraries please correctly import UMP (Win, Mac, Linux) package"); } if (_useExternalLibrariesProp.boolValue) { EditorGUILayout.BeginVertical(GUI.skin.box); } EditorGUILayout.PropertyField(_useExternalLibrariesProp, new GUIContent("Use installed VLC", "Use external/installed VLC player libraries for all UMP instances (global). Path to installed VLC player directory will be obtained automatically")); if (useInstalled) { _useExternalLibrariesProp.boolValue = true; } if (settings.UseExternalLibraries) { var librariesPath = settings.GetLibrariesPath(UMPSettings.RuntimePlatform, true); if (!UMPSettings.ContainsLibVLC(librariesPath)) { librariesPath = string.Empty; GUI.color = Color.yellow; EditorGUILayout.BeginVertical(EditorStyles.textArea); EditorGUILayout.LabelField("Warning: Can't find installed VLC player software, please make sure that:\n" + "* Installed VLC player bit equals Unity Editor bit, eg., 'VLC Player 64 bit' == 'Unity Editor 64 bit'\n\n" + "* Use installer version from official site", _warningLabel); GUI.color = Color.white; var vlcUrl = string.Empty; switch (UMPSettings.RuntimePlatform) { case UMPSettings.Platforms.Win: vlcUrl = string.Format("http://get.videolan.org/vlc/{0}/win64/vlc-{0}-win64.exe", VLC_VERSION); if (UMPSettings.EditorBitMode == UMPSettings.BitModes.x86) { vlcUrl = string.Format("http://get.videolan.org/vlc/{0}/win32/vlc-{0}-win32.exe", VLC_VERSION); } break; case UMPSettings.Platforms.Mac: vlcUrl = string.Format("http://get.videolan.org/vlc/{0}/macosx/vlc-{0}.dmg", VLC_VERSION); break; } if (!string.IsNullOrEmpty(vlcUrl)) { _warningLabel.normal.textColor = Color.blue; EditorGUILayout.LabelField(string.Format("{0} (Editor {1})", vlcUrl, UMPSettings.EditorBitModeFolderName), _warningLabel); _warningLabel.normal.textColor = Color.black; Rect urlRect = GUILayoutUtility.GetLastRect(); if (Event.current.type == EventType.MouseUp && urlRect.Contains(Event.current.mousePosition)) { Application.OpenURL(vlcUrl); } } EditorGUILayout.EndVertical(); } EditorGUILayout.Space(); EditorGUILayout.LabelField(new GUIContent("Libraries path", @"Path to installed VLC player libraries, eg., 'C:\Program Files\VideoLAN\VLC'")); if (!librariesPath.Equals(string.Empty)) { _librariesPathProp.stringValue = librariesPath; EditorGUI.BeginDisabledGroup(true); ShowMessageBox(MessageType.None, _librariesPathProp.stringValue); EditorGUI.EndDisabledGroup(); } else { ShowMessageBox(MessageType.Warning, "Path to installed VLC player directory can't be obtained automatically, try to use custom path to your libVLC libraries"); _librariesPathProp.stringValue = EditorGUILayout.TextField(_librariesPathProp.stringValue); } if (UMPSettings.ContainsLibVLC(_librariesPathProp.stringValue)) { ShowMessageBox(MessageType.Info, "Path is correct"); } else { ShowMessageBox(MessageType.Error, @"Can't find VLC player libraries, try to check if your path is correct, eg., 'C:\Program Files\VideoLAN\VLC'"); } } if (_useExternalLibrariesProp.boolValue) { EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); #endregion // Display the Mobile options #region Mobile EditorGUILayout.BeginVertical(GUI.skin.box); if (installedMobilePlatforms.Length > 0) { EditorGUILayout.LabelField("Mobile", EditorStyles.boldLabel); _chosenMobilePlatform = GUILayout.SelectionGrid(_chosenMobilePlatform, installedMobilePlatforms, installedMobilePlatforms.Length, EditorStyles.miniButton); EditorGUILayout.BeginVertical(GUI.skin.box); EditorGUILayout.LabelField(new GUIContent("Player Types", "Choose player types that will be used in your project")); ShowMessageBox(MessageType.Info, "Disabled players will be not included into your build (reducing the file size of your build)"); GUILayout.BeginHorizontal(); 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 ((settings.PlayersAndroid & ~playerType) > 0) { playersAndroid[i] = !playersAndroid[i]; settings.PlayersAndroid = playersAndroid[i] ? settings.PlayersAndroid | playerType : settings.PlayersAndroid & ~playerType; UpdateMobileLibraries(UMPSettings.Platforms.Android, settings.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 ((settings.PlayersIPhone & ~playerType) > 0) { playersIPhone[i] = !playersIPhone[i]; settings.PlayersIPhone = playersIPhone[i] ? settings.PlayersIPhone | playerType : settings.PlayersIPhone & ~playerType; UpdateMobileLibraries(UMPSettings.Platforms.iOS, settings.PlayersIPhone); } } } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); if (installedMobilePlatforms[_chosenMobilePlatform] == UMPSettings.Platforms.Android.ToString()) { GUILayout.BeginVertical(GUI.skin.box); if (GUILayout.Button(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)"), _showExportedPaths ? _buttonStyleToggled : EditorStyles.miniButton)) { _showExportedPaths = !_showExportedPaths; } if (_showExportedPaths) { scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandHeight(false)); _exportedPathsSize = EditorGUILayout.IntField(new GUIContent("Size", "Amount of exported videos"), settings.AndroidExportedPaths.Length, GUILayout.ExpandWidth(true)); if (_exportedPathsSize < 0) { _exportedPathsSize = 0; } _cachedExportedPaths = new string[_exportedPathsSize]; if (_exportedPathsSize >= 0) { _cachedExportedPaths = new string[_exportedPathsSize]; for (int i = 0; i < settings.AndroidExportedPaths.Length; i++) { if (i < _exportedPathsSize) { _cachedExportedPaths[i] = settings.AndroidExportedPaths[i]; } } } EditorGUIUtility.labelWidth = 60; for (int i = 0; i < _cachedExportedPaths.Length; i++) { _cachedExportedPaths[i] = EditorGUILayout.TextField("Path " + i + ":", _cachedExportedPaths[i]); } EditorGUIUtility.labelWidth = cachedLabelWidth; settings.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 = settings.AndroidExportedPaths.Length > filePaths.Length ? settings.AndroidExportedPaths.Length : filePaths.Length; _cachedExportedPaths = new string[arrayLength]; for (int i = 0; i < arrayLength; i++) { if (i < settings.AndroidExportedPaths.Length) { _cachedExportedPaths[i] = settings.AndroidExportedPaths[i]; } if (i < filePaths.Length) { _cachedExportedPaths[i] = filePaths[i]; } } settings.AndroidExportedPaths = _cachedExportedPaths; } } break; } } GUILayout.EndVertical(); } } EditorGUILayout.EndVertical(); #endregion // Display the Services options #region Services EditorGUILayout.BeginVertical(GUI.skin.box); EditorGUILayout.LabelField("Services", EditorStyles.boldLabel); EditorGUILayout.LabelField(new GUIContent("Youtube Decrypt Function", "Uses for decrypt the direct links to Youtube video")); _youtubeDecryptFunctionProp.stringValue = EditorGUILayout.TextField(_youtubeDecryptFunctionProp.stringValue); EditorGUILayout.EndVertical(); #endregion serializedObject.ApplyModifiedProperties(); }
public static void UMPGUI() { if (!_preloaded) { _umpSettings = UMPSettings.Instance; _preloaded = true; } var chachedLabelColor = EditorStyles.label.normal.textColor; var cachedFontStyle = EditorStyles.label.fontStyle; _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 = chachedLabelColor; 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 = chachedLabelColor; 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 = chachedLabelColor; EditorGUILayout.Space(); EditorGUILayout.LabelField("Mobile platforms:", EditorStyles.boldLabel); EditorGUILayout.Space(); _umpSettings.UseAndroidNative = EditorGUILayout.Toggle(new GUIContent("Use Android native player", "Will be using Android native media player (MediaPlayer) for all UMP instances (global)."), _umpSettings.UseAndroidNative); if (_nativeAndroidLibraryPrepare != _umpSettings.UseAndroidNative) { List <string> libs = new List <string>(); libs.AddRange(Directory.GetFiles(Application.dataPath + "/UniversalMediaPlayer/Plugins/Android/libs/armeabi-v7a")); libs.AddRange(Directory.GetFiles(Application.dataPath + "/UniversalMediaPlayer/Plugins/Android/libs/x86")); foreach (var lib in libs) { if (lib.Contains(".meta") && !lib.Contains("libUniversalMediaPlayer")) { File.SetAttributes(lib, FileAttributes.Normal); string metaData = File.ReadAllText(lib); var match = Regex.Match(metaData, @"Android.*\s*enabled:."); if (match.Success) { metaData = Regex.Replace(metaData, @"Android.*\s*enabled:." + (!_nativeAndroidLibraryPrepare ? 1 : 0), match.Value + (_nativeAndroidLibraryPrepare ? 1 : 0)); File.WriteAllText(lib, metaData); } } } libs.Clear(); AssetDatabase.Refresh(); } _nativeAndroidLibraryPrepare = _umpSettings.UseAndroidNative; EditorGUILayout.Space(); _umpSettings.UseIPhoneNative = EditorGUILayout.Toggle(new GUIContent("Use iOS native player", "Will be using iOS native media player (AVPlayer) for all UMP instances (global)."), _umpSettings.UseIPhoneNative); if (_nativeIPhoneLibraryPrepare != _umpSettings.UseIPhoneNative) { List <string> libs = new List <string>(); libs.AddRange(Directory.GetFiles(Application.dataPath + "/UniversalMediaPlayer/Plugins/iOS")); foreach (var lib in libs) { if (lib.Contains(".meta")) { if (!Path.GetFileNameWithoutExtension(lib).Contains("Base")) { File.SetAttributes(lib, FileAttributes.Normal); string metaData = File.ReadAllText(lib); var match = Regex.Match(metaData, @"iOS.*\s*enabled:."); if (match.Success) { var isFFmpeg = (lib.Contains("FFmpeg") || lib.Contains("framework")); var enable = isFFmpeg ? !_umpSettings.UseIPhoneNative : _umpSettings.UseIPhoneNative; metaData = Regex.Replace(metaData, @"iOS.*\s*enabled:." + (!enable ? 1 : 0), match.Value + (enable ? 1 : 0)); File.WriteAllText(lib, metaData); } } } } libs.Clear(); AssetDatabase.Refresh(); } _nativeIPhoneLibraryPrepare = _umpSettings.UseIPhoneNative; }
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(); } }
public override void OnInspectorGUI() { serializedObject.Update(); var umpEditor = (UniversalMediaPlayer)target; EditorGUIUtility.labelWidth = 0; EditorGUIUtility.fieldWidth = 0; 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.miniButton); _toggleButton.normal.background = EditorStyles.miniButton.active.background; } if (GUILayout.Button("Advanced options", _useAdvancedProp.boolValue ? _toggleButton : EditorStyles.miniButton)) { _useAdvancedProp.boolValue = !_useAdvancedProp.boolValue; _availablePlatforms = AvailablePlatforms; } 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 = AvailablePlatforms; } 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] == DESKTOP_CATEGORY_NAME) { EditorGUI.BeginDisabledGroup(Application.isPlaying); #region Audio Option GUILayout.BeginHorizontal(); GUILayout.Space(13); EditorGUILayout.PropertyField(_audioSourcesDesktopProp, new GUIContent("Audio Sources:"), true); GUILayout.EndHorizontal(); EditorGUILayout.Space(); #endregion #region Decoding Options EditorGUILayout.PropertyField(_hardwareDecodingDesktopProp, new GUIContent("Hardware decoding: ", "This allows hardware decoding when available."), false); if (_hardwareDecodingDesktopProp.intValue == (int)PlayerOptions.State.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 (UMPSettings.EditorBitMode == UMPSettings.BitModes.x86) { var warningLabel = new GUIStyle(EditorStyles.textArea); warningLabel.fontStyle = FontStyle.Italic; EditorGUILayout.LabelField("Doesn't support on current bit system and will be ignored and swiched to 'Enable' state.", warningLabel); } } if (_hardwareDecodingDesktopProp.intValue == (int)PlayerOptions.State.Enable) { GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Automatic")); } EditorGUILayout.Space(); #endregion #region Flip Options _flipVerticallyDesktopProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Flip vertically: ", "Flip video frame vertically when we get it from native library (CPU usage cost)."), _flipVerticallyDesktopProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Flip video frame vertically when we get it from native library (CPU usage cost).")); #endregion #region Dublicate Options _outputToFileDesktopProp.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)."), _outputToFileDesktopProp.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 (_outputToFileDesktopProp.boolValue) { _displayOutputDesktopProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Display source video: ", "Display source video when duplicate data to a file."), _displayOutputDesktopProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Display source video when duplicate data to a file.")); _outputFilePathDesktopProp.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')."), _outputFilePathDesktopProp.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 _rtspOverTcpDesktopProp.boolValue = EditorGUILayout.Toggle(new GUIContent("RTP over RTSP (TCP): ", "Use RTP over RTSP (TCP) (HTTP default)."), _rtspOverTcpDesktopProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use RTP over RTSP (TCP) (HTTP default).")); #endregion EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(umpEditor.IsReady); #region Caching Options _fileCachingDesktopProp.intValue = EditorGUILayout.IntField(new GUIContent("File caching (ms): ", "Caching value for local files, in milliseconds."), _fileCachingDesktopProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for local files, in milliseconds.")); _fileCachingDesktopProp.intValue = Mathf.Clamp(_fileCachingDesktopProp.intValue, 0, 60000); _liveCachingDesktopProp.intValue = EditorGUILayout.IntField(new GUIContent("Live capture caching (ms): ", "Caching value for cameras and microphones, in milliseconds."), _liveCachingDesktopProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for cameras and microphones, in milliseconds.")); _liveCachingDesktopProp.intValue = Mathf.Clamp(_liveCachingDesktopProp.intValue, 0, 60000); _diskCachingDesktopProp.intValue = EditorGUILayout.IntField(new GUIContent("Disc caching (ms): ", "Caching value for optical media, in milliseconds."), _diskCachingDesktopProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for optical media, in milliseconds.")); _diskCachingDesktopProp.intValue = Mathf.Clamp(_diskCachingDesktopProp.intValue, 0, 60000); _networkCachingDesktopProp.intValue = EditorGUILayout.IntField(new GUIContent("Network caching (ms): ", "Caching value for network resources, in milliseconds."), _networkCachingDesktopProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for network resources, in milliseconds.")); _networkCachingDesktopProp.intValue = Mathf.Clamp(_networkCachingDesktopProp.intValue, 0, 60000); #endregion EditorGUI.EndDisabledGroup(); } #endregion #region WebGL Options if (_availablePlatforms[_chosenPlatformProp.intValue] == WEBGL_CATEGORY_NAME) { 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] == ANDROID_CATEGORY_NAME) { if (!UMPPreference.Instance.UseAndroidNative) { #region Decoding Options EditorGUILayout.PropertyField(_hardwareDecodingAndroidProp, new GUIContent("Hardware decoding: ", "This allows hardware decoding when available."), false); if (_hardwareDecodingAndroidProp.intValue == (int)PlayerOptions.State.Default) { GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "HW decoder will be used")); } if (_hardwareDecodingAndroidProp.intValue == (int)PlayerOptions.State.Enable) { GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Force HW acceleration even for unknown devices")); } EditorGUILayout.Space(); #endregion #region Background Options _playInBackgroundAndroidProb.boolValue = EditorGUILayout.Toggle(new GUIContent("Play in background: ", "Continue play video when application in background."), _playInBackgroundAndroidProb.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Continue play video when application in background.")); #endregion #region RTP/RTSP/SDP Options _rtspOverTcpAndroidProp.boolValue = EditorGUILayout.Toggle(new GUIContent("RTP over RTSP (TCP): ", "Use RTP over RTSP (TCP) (HTTP default)."), _rtspOverTcpAndroidProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use RTP over RTSP (TCP) (HTTP default).")); #endregion #region Caching Options _fileCachingAndroidProp.intValue = EditorGUILayout.IntField(new GUIContent("File caching (ms): ", "Caching value for local files, in milliseconds."), _fileCachingAndroidProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for local files, in milliseconds.")); _fileCachingAndroidProp.intValue = Mathf.Clamp(_fileCachingAndroidProp.intValue, 0, 60000); _liveCachingAndroidProp.intValue = EditorGUILayout.IntField(new GUIContent("Live capture caching (ms): ", "Caching value for cameras and microphones, in milliseconds."), _liveCachingAndroidProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for cameras and microphones, in milliseconds.")); _liveCachingAndroidProp.intValue = Mathf.Clamp(_liveCachingAndroidProp.intValue, 0, 60000); _diskCachingAndroidProp.intValue = EditorGUILayout.IntField(new GUIContent("Disc caching (ms): ", "Caching value for optical media, in milliseconds."), _diskCachingAndroidProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for optical media, in milliseconds.")); _diskCachingAndroidProp.intValue = Mathf.Clamp(_diskCachingAndroidProp.intValue, 0, 60000); _networkCachingAndroidProp.intValue = EditorGUILayout.IntField(new GUIContent("Network caching (ms): ", "Caching value for network resources, in milliseconds."), _networkCachingAndroidProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for network resources, in milliseconds.")); _networkCachingAndroidProp.intValue = Mathf.Clamp(_networkCachingAndroidProp.intValue, 0, 60000); #endregion } else { var warningLabel = new GUIStyle(EditorStyles.textArea); warningLabel.fontStyle = FontStyle.Bold; EditorGUILayout.LabelField("Doesn't support any additional options for Android native player in this version.", warningLabel); } } #endregion EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(Application.isPlaying); #region IPhone Options if (_availablePlatforms[_chosenPlatformProp.intValue] == IPHONE_CATEGORY_NAME) { if (!UMPPreference.Instance.UseIPhoneNative) { #region VideoToolbox Options _videoToolboxIPhoneProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Hardware decoding: ", "This allows hardware decoding when available (enable VideoToolbox decoding)."), _videoToolboxIPhoneProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "This allows hardware decoding when available (enable VideoToolbox decoding).")); if (_videoToolboxIPhoneProp.boolValue) { _videoToolboxMaxFrameWidthIPhoneProp.intValue = EditorGUILayout.IntField(new GUIContent("Max width of output frame: ", "Max possible video resolution for hardware decoding."), _videoToolboxMaxFrameWidthIPhoneProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Max possible video resolution for hardware decoding.")); _videoToolboxMaxFrameWidthIPhoneProp.intValue = Mathf.Clamp(_videoToolboxMaxFrameWidthIPhoneProp.intValue, 0, 32768); _videoToolboxAsyncIPhoneProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Async decompression: ", "Use asynchronous decompression for hardware frame decoding."), _videoToolboxAsyncIPhoneProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use asynchronous decompression for hardware frame decoding.")); if (_videoToolboxAsyncIPhoneProp.boolValue) { _videoToolboxWaitAsyncIPhoneProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Wait for asynchronous frames: ", "Wait when frames is ready."), _videoToolboxWaitAsyncIPhoneProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Wait when frames is ready.")); } } EditorGUILayout.Space(); #endregion #region Background Options _playInBackgroundIPhoneProb.boolValue = EditorGUILayout.Toggle(new GUIContent("Play in background: ", "Continue play video when application in background."), _playInBackgroundIPhoneProb.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Continue play video when application in background.")); #endregion #region RTP/RTSP/SDP Options _rtspOverTcpIPhoneProp.boolValue = EditorGUILayout.Toggle(new GUIContent("RTP over RTSP (TCP): ", "Use RTP over RTSP (TCP) (HTTP default)."), _rtspOverTcpIPhoneProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use RTP over RTSP (TCP) (HTTP default).")); #endregion #region Buffer Options _packetBufferingIPhoneProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Packet buffering: ", "Pause output until enough packets have been read after stalling."), _packetBufferingIPhoneProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Pause output until enough packets have been read after stalling.")); _maxBufferSizeIPhoneProp.intValue = EditorGUILayout.IntField(new GUIContent("Max buffer size: ", "Max buffer size should be pre-read (in bytes)."), _maxBufferSizeIPhoneProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Max buffer size should be pre-read.")); _maxBufferSizeIPhoneProp.intValue = Mathf.Clamp(_maxBufferSizeIPhoneProp.intValue, 0, 15 * 1024 * 1024); _minFramesIPhoneProp.intValue = EditorGUILayout.IntField(new GUIContent("Min frames: ", "Minimal frames to stop pre-reading."), _minFramesIPhoneProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Minimal frames to stop pre-reading.")); _minFramesIPhoneProp.intValue = Mathf.Clamp(_minFramesIPhoneProp.intValue, 5, 50000); _infbufIPhoneProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Infbuf: ", "Don't limit the input buffer size (useful with realtime streams)."), _infbufIPhoneProp.boolValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Don't limit the input buffer size (useful with realtime streams).")); EditorGUILayout.Space(); #endregion #region Frame Options _framedropIPhoneProp.intValue = EditorGUILayout.IntField(new GUIContent("Framedrop: ", "Drop frames when cpu is too slow."), _framedropIPhoneProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Drop frames when cpu is too slow.")); _framedropIPhoneProp.intValue = Mathf.Clamp(_framedropIPhoneProp.intValue, -1, 120); _maxFpsIPhoneProp.intValue = EditorGUILayout.IntField(new GUIContent("Max fps: ", "Drop frames in video whose fps is greater than max-fps."), _maxFpsIPhoneProp.intValue); GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Drop frames in video whose fps is greater than max-fps.")); _maxFpsIPhoneProp.intValue = Mathf.Clamp(_maxFpsIPhoneProp.intValue, -1, 120); #endregion } else { var warningLabel = new GUIStyle(EditorStyles.textArea); warningLabel.fontStyle = FontStyle.Bold; EditorGUILayout.LabelField("Doesn't support any additional options for iOS native player in this version.", warningLabel); } } #endregion EditorGUI.EndDisabledGroup(); EditorGUIUtility.labelWidth = _cachedLabelWidth; } else { _fileCachingDesktopProp.intValue = PlayerOptions.DEFAULT_CACHING_VALUE; _liveCachingDesktopProp.intValue = PlayerOptions.DEFAULT_CACHING_VALUE; _diskCachingDesktopProp.intValue = PlayerOptions.DEFAULT_CACHING_VALUE; _networkCachingDesktopProp.intValue = PlayerOptions.DEFAULT_CACHING_VALUE; _fixedVideoWidthProp.intValue = -1; _fixedVideoHeightProp.intValue = -1; } if (UMPSettings.Instance.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(_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(); } }