UMPEditor.cs 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. using System;
  2. using UnityEditor;
  3. using UnityEngine;
  4. using UMP;
  5. using System.Collections.Generic;
  6. [CustomEditor(typeof(UniversalMediaPlayer))]
  7. [CanEditMultipleObjects]
  8. [Serializable]
  9. public class UMPEditor : Editor
  10. {
  11. SerializedProperty _renderingObjectsProp;
  12. SerializedProperty _pathProp;
  13. SerializedProperty _autoPlayProp;
  14. SerializedProperty _loopProp;
  15. SerializedProperty _loopSmoothProp;
  16. SerializedProperty _muteProp;
  17. SerializedProperty _useAdvancedProp;
  18. SerializedProperty _useFixedSizeProp;
  19. SerializedProperty _fixedVideoWidthProp;
  20. SerializedProperty _fixedVideoHeightProp;
  21. SerializedProperty _chosenPlatformProp;
  22. SerializedProperty _volumeProp;
  23. SerializedProperty _playRateProp;
  24. SerializedProperty _positionProp;
  25. SerializedProperty _logDetailProp;
  26. SerializedProperty _lastEventMsgProp;
  27. SerializedProperty _pathPreparedEventProp;
  28. SerializedProperty _openingEventProp;
  29. SerializedProperty _bufferingEventProp;
  30. SerializedProperty _imageReadyEventProp;
  31. SerializedProperty _preparedEventProp;
  32. SerializedProperty _playingEventProp;
  33. SerializedProperty _pausedEventProp;
  34. SerializedProperty _stoppedEventProp;
  35. SerializedProperty _endReachedEventProp;
  36. SerializedProperty _encounteredErrorEventProp;
  37. SerializedProperty _timeChangedEventProp;
  38. SerializedProperty _positionChangedEventProp;
  39. SerializedProperty _snapshotTakenEventProp;
  40. #region Desktop Options
  41. SerializedProperty _desktopAudioOutputsProp;
  42. SerializedProperty _desktopHardwareDecodingProp;
  43. SerializedProperty _desktopVideoBufferSizeProp;
  44. SerializedProperty _desktopFlipVerticallyProp;
  45. SerializedProperty _desktopOutputToFileProp;
  46. SerializedProperty _desktopDisplayOutputProp;
  47. SerializedProperty _desktopOutputFilePathProp;
  48. SerializedProperty _desktopRtspOverTcpProp;
  49. SerializedProperty _desktopFileCachingProp;
  50. SerializedProperty _desktopLiveCachingProp;
  51. SerializedProperty _desktopDiskCachingProp;
  52. SerializedProperty _desktopNetworkCachingProp;
  53. #endregion
  54. #region Android Options
  55. SerializedProperty _androidPlayerTypeProp;
  56. SerializedProperty _androidHardwareAccelerationProp;
  57. SerializedProperty _androidOpenGLDecodingProp;
  58. SerializedProperty _androidVideoChromaProp;
  59. SerializedProperty _androidPlayInBackgroundProb;
  60. SerializedProperty _androidRtspOverTcpProp;
  61. SerializedProperty _androidNetworkCachingProp;
  62. #endregion
  63. #region IPhone Options
  64. SerializedProperty _iphonePlayerTypeProp;
  65. SerializedProperty _iphoneFlipVerticallyProp;
  66. SerializedProperty _iphoneVideoToolboxProp;
  67. SerializedProperty _iphoneVideoToolboxMaxFrameWidthProp;
  68. SerializedProperty _iphoneVideoToolboxAsyncProp;
  69. SerializedProperty _iphoneVideoToolboxWaitAsyncProp;
  70. SerializedProperty _iphonePlayInBackgroundProb;
  71. SerializedProperty _iphoneRtspOverTcpProp;
  72. SerializedProperty _iphonePacketBufferingProp;
  73. SerializedProperty _iphoneMaxBufferSizeProp;
  74. SerializedProperty _iphoneMinFramesProp;
  75. SerializedProperty _iphoneInfbufProp;
  76. SerializedProperty _iphoneFramedropProp;
  77. SerializedProperty _iphoneMaxFpsProp;
  78. #endregion
  79. private string[] _availablePlatforms;
  80. private string _externalPath = string.Empty;
  81. private bool _showEventsListeners;
  82. private FontStyle _cachedFontStyle;
  83. private Color _cachedTextColor;
  84. private float _cachedLabelWidth;
  85. private bool _cachedLabelWordWrap;
  86. private static GUIStyle _toggleButton = null;
  87. private void OnEnable()
  88. {
  89. // Setup the SerializedProperties
  90. _renderingObjectsProp = serializedObject.FindProperty("_renderingObjects");
  91. _pathProp = serializedObject.FindProperty("_path");
  92. _autoPlayProp = serializedObject.FindProperty("_autoPlay");
  93. _loopProp = serializedObject.FindProperty("_loop");
  94. _loopSmoothProp = serializedObject.FindProperty("_loopSmooth");
  95. _muteProp = serializedObject.FindProperty("_mute");
  96. _useAdvancedProp = serializedObject.FindProperty("_useAdvanced");
  97. _useFixedSizeProp = serializedObject.FindProperty("_useFixedSize");
  98. _fixedVideoWidthProp = serializedObject.FindProperty("_fixedVideoWidth");
  99. _fixedVideoHeightProp = serializedObject.FindProperty("_fixedVideoHeight");
  100. _chosenPlatformProp = serializedObject.FindProperty("_chosenPlatform");
  101. _volumeProp = serializedObject.FindProperty("_volume");
  102. _playRateProp = serializedObject.FindProperty("_playRate");
  103. _positionProp = serializedObject.FindProperty("_position");
  104. _logDetailProp = serializedObject.FindProperty("_logDetail");
  105. _lastEventMsgProp = serializedObject.FindProperty("_lastEventMsg");
  106. _pathPreparedEventProp = serializedObject.FindProperty("_pathPreparedEvent");
  107. _openingEventProp = serializedObject.FindProperty("_openingEvent");
  108. _bufferingEventProp = serializedObject.FindProperty("_bufferingEvent");
  109. _imageReadyEventProp = serializedObject.FindProperty("_imageReadyEvent");
  110. _preparedEventProp = serializedObject.FindProperty("_preparedEvent");
  111. _playingEventProp = serializedObject.FindProperty("_playingEvent");
  112. _pausedEventProp = serializedObject.FindProperty("_pausedEvent");
  113. _stoppedEventProp = serializedObject.FindProperty("_stoppedEvent");
  114. _endReachedEventProp = serializedObject.FindProperty("_endReachedEvent");
  115. _encounteredErrorEventProp = serializedObject.FindProperty("_encounteredErrorEvent");
  116. _timeChangedEventProp = serializedObject.FindProperty("_timeChangedEvent");
  117. _positionChangedEventProp = serializedObject.FindProperty("_positionChangedEvent");
  118. _snapshotTakenEventProp = serializedObject.FindProperty("_snapshotTakenEvent");
  119. #region Desktop Options
  120. _desktopAudioOutputsProp = serializedObject.FindProperty("_desktopAudioOutputs");
  121. _desktopHardwareDecodingProp = serializedObject.FindProperty("_desktopHardwareDecoding");
  122. _desktopFlipVerticallyProp = serializedObject.FindProperty("_desktopFlipVertically");
  123. _desktopVideoBufferSizeProp = serializedObject.FindProperty("_desktopVideoBufferSize");
  124. _desktopOutputToFileProp = serializedObject.FindProperty("_desktopOutputToFile");
  125. _desktopDisplayOutputProp = serializedObject.FindProperty("_desktopDisplayOutput");
  126. _desktopOutputFilePathProp = serializedObject.FindProperty("_desktopOutputFilePath");
  127. _desktopRtspOverTcpProp = serializedObject.FindProperty("_desktopRtspOverTcp");
  128. _desktopFileCachingProp = serializedObject.FindProperty("_desktopFileCaching");
  129. _desktopLiveCachingProp = serializedObject.FindProperty("_desktopLiveCaching");
  130. _desktopDiskCachingProp = serializedObject.FindProperty("_desktopDiskCaching");
  131. _desktopNetworkCachingProp = serializedObject.FindProperty("_desktopNetworkCaching");
  132. #endregion
  133. #region Android Options
  134. _androidPlayerTypeProp = serializedObject.FindProperty("_androidPlayerType");
  135. _androidHardwareAccelerationProp = serializedObject.FindProperty("_androidHardwareAcceleration");
  136. _androidOpenGLDecodingProp = serializedObject.FindProperty("_androidOpenGLDecoding");
  137. _androidVideoChromaProp = serializedObject.FindProperty("_androidVideoChroma");
  138. _androidPlayInBackgroundProb = serializedObject.FindProperty("_androidPlayInBackground");
  139. _androidRtspOverTcpProp = serializedObject.FindProperty("_androidRtspOverTcp");
  140. _androidNetworkCachingProp = serializedObject.FindProperty("_androidNetworkCaching");
  141. #endregion
  142. #region IPhone Options
  143. _iphonePlayerTypeProp = serializedObject.FindProperty("_iphonePlayerType");
  144. _iphoneFlipVerticallyProp = serializedObject.FindProperty("_iphoneFlipVertically");
  145. _iphoneVideoToolboxProp = serializedObject.FindProperty("_iphoneVideoToolbox");
  146. _iphoneVideoToolboxMaxFrameWidthProp = serializedObject.FindProperty("_iphoneVideoToolboxMaxFrameWidth");
  147. _iphoneVideoToolboxAsyncProp = serializedObject.FindProperty("_iphoneVideoToolboxAsync");
  148. _iphoneVideoToolboxWaitAsyncProp = serializedObject.FindProperty("_iphoneVideoToolboxWaitAsync");
  149. _iphonePlayInBackgroundProb = serializedObject.FindProperty("_iphonePlayInBackground");
  150. _iphoneRtspOverTcpProp = serializedObject.FindProperty("_iphoneRtspOverTcp");
  151. _iphonePacketBufferingProp = serializedObject.FindProperty("_iphonePacketBuffering");
  152. _iphoneMaxBufferSizeProp = serializedObject.FindProperty("_iphoneMaxBufferSize");
  153. _iphoneMinFramesProp = serializedObject.FindProperty("_iphoneMinFrames");
  154. _iphoneInfbufProp = serializedObject.FindProperty("_iphoneInfbuf");
  155. _iphoneFramedropProp = serializedObject.FindProperty("_iphoneFramedrop");
  156. _iphoneMaxFpsProp = serializedObject.FindProperty("_iphoneMaxFps");
  157. #endregion
  158. }
  159. public override void OnInspectorGUI()
  160. {
  161. serializedObject.Update();
  162. var umpEditor = (UniversalMediaPlayer)target;
  163. var settings = UMPSettings.Instance;
  164. EditorGUI.BeginChangeCheck();
  165. _cachedFontStyle = EditorStyles.label.fontStyle;
  166. _cachedTextColor = EditorStyles.textField.normal.textColor;
  167. _cachedLabelWordWrap = EditorStyles.label.wordWrap;
  168. #region Rendering Field
  169. EditorGUILayout.Space();
  170. EditorGUILayout.PropertyField(_renderingObjectsProp, new GUIContent("Rendering GameObjects:"), true);
  171. #endregion
  172. #region Path Field
  173. EditorGUILayout.Space();
  174. EditorStyles.label.fontStyle = FontStyle.Bold;
  175. EditorGUILayout.LabelField("Path to video file:");
  176. EditorStyles.label.fontStyle = _cachedFontStyle;
  177. EditorStyles.textField.wordWrap = true;
  178. _pathProp.stringValue = EditorGUILayout.TextField(_pathProp.stringValue, GUILayout.Height(30));
  179. EditorStyles.textField.wordWrap = false;
  180. #endregion
  181. #region Additional Fields
  182. EditorGUILayout.Space();
  183. EditorStyles.label.fontStyle = FontStyle.Bold;
  184. EditorGUILayout.LabelField("Additional properties:");
  185. EditorStyles.label.fontStyle = _cachedFontStyle;
  186. GUILayout.BeginVertical("Box");
  187. GUILayout.BeginHorizontal();
  188. EditorGUILayout.LabelField("AutoPlay:", GUILayout.MinWidth(60));
  189. _autoPlayProp.boolValue = EditorGUILayout.Toggle(_autoPlayProp.boolValue, EditorStyles.radioButton);
  190. if (!_loopSmoothProp.boolValue)
  191. EditorGUILayout.LabelField("Loop:", GUILayout.MinWidth(36));
  192. else
  193. EditorGUILayout.LabelField("Loop(smooth):", GUILayout.MinWidth(90));
  194. _loopProp.boolValue = EditorGUILayout.Toggle(_loopProp.boolValue, EditorStyles.radioButton, GUILayout.MaxWidth(20));
  195. EditorGUI.BeginDisabledGroup(Application.isPlaying);
  196. _loopSmoothProp.boolValue = EditorGUILayout.Toggle(_loopSmoothProp.boolValue, EditorStyles.radioButton);
  197. EditorGUI.EndDisabledGroup();
  198. EditorGUILayout.LabelField("Mute:", GUILayout.MinWidth(36));
  199. _muteProp.boolValue = EditorGUILayout.Toggle(_muteProp.boolValue, EditorStyles.radioButton);
  200. GUILayout.EndHorizontal();
  201. if (_toggleButton == null)
  202. {
  203. _toggleButton = new GUIStyle(EditorStyles.miniButtonMid);
  204. _toggleButton.normal.background = EditorStyles.miniButton.active.background;
  205. }
  206. if (GUILayout.Button("Advanced options", _useAdvancedProp.boolValue ? _toggleButton : EditorStyles.miniButtonMid))
  207. {
  208. _useAdvancedProp.boolValue = !_useAdvancedProp.boolValue;
  209. _availablePlatforms = settings.GetInstalledPlatforms(UMPSettings.Desktop | UMPSettings.Mobile);
  210. }
  211. if (_useAdvancedProp.boolValue)
  212. {
  213. EditorGUI.BeginDisabledGroup(Application.isPlaying);
  214. _cachedLabelWidth = EditorGUIUtility.labelWidth;
  215. EditorGUIUtility.labelWidth = 170;
  216. _useFixedSizeProp.boolValue = EditorGUILayout.Toggle("Use fixed video size:", _useFixedSizeProp.boolValue);
  217. if (_useFixedSizeProp.boolValue)
  218. {
  219. _fixedVideoWidthProp.intValue = EditorGUILayout.IntField(new GUIContent("Width: ", "Fixed video width."), _fixedVideoWidthProp.intValue);
  220. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Fixed video width."));
  221. _fixedVideoWidthProp.intValue = Mathf.Clamp(_fixedVideoWidthProp.intValue, 1, 7680);
  222. _fixedVideoHeightProp.intValue = EditorGUILayout.IntField(new GUIContent("Height: ", "Fixed video height."), _fixedVideoHeightProp.intValue);
  223. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Fixed video height."));
  224. _fixedVideoHeightProp.intValue = Mathf.Clamp(_fixedVideoHeightProp.intValue, 1, 7680);
  225. }
  226. else
  227. {
  228. _fixedVideoWidthProp.intValue = 0;
  229. _fixedVideoHeightProp.intValue = 0;
  230. }
  231. EditorGUI.EndDisabledGroup();
  232. EditorGUILayout.Space();
  233. if (_availablePlatforms == null || _availablePlatforms.Length <= 0)
  234. _availablePlatforms = settings.GetInstalledPlatforms(UMPSettings.Desktop | UMPSettings.Mobile);
  235. if (_availablePlatforms.Length <= 0)
  236. {
  237. var warningLabel = new GUIStyle(EditorStyles.textArea);
  238. warningLabel.fontStyle = FontStyle.Bold;
  239. EditorGUILayout.LabelField("Can't find 'UniversalMediaPlayer' asset folder, please check your Unity UMP preferences.", warningLabel);
  240. EditorStyles.label.normal.textColor = _cachedTextColor;
  241. EditorStyles.label.fontStyle = _cachedFontStyle;
  242. if (EditorGUI.EndChangeCheck())
  243. serializedObject.ApplyModifiedProperties();
  244. return;
  245. }
  246. _chosenPlatformProp.intValue = GUILayout.SelectionGrid(_chosenPlatformProp.intValue, _availablePlatforms, _availablePlatforms.Length, EditorStyles.miniButton);
  247. _chosenPlatformProp.intValue = Mathf.Clamp(_chosenPlatformProp.intValue, 0, _availablePlatforms.Length - 1);
  248. #region Desktop Options
  249. if (_availablePlatforms[_chosenPlatformProp.intValue] == UMPSettings.DESKTOP_CATEGORY_NAME)
  250. {
  251. EditorGUI.BeginDisabledGroup(Application.isPlaying);
  252. #region Audio Option
  253. GUILayout.BeginHorizontal();
  254. GUILayout.Space(13);
  255. EditorGUILayout.PropertyField(_desktopAudioOutputsProp, new GUIContent("Audio Outputs:"), true);
  256. GUILayout.EndHorizontal();
  257. EditorGUILayout.Space();
  258. #endregion
  259. #region Decoding Options
  260. EditorGUILayout.PropertyField(_desktopHardwareDecodingProp, new GUIContent("Hardware decoding: ", "This allows hardware decoding when available."), false);
  261. if (_desktopHardwareDecodingProp.intValue == (int)PlayerOptions.States.Default)
  262. {
  263. var hardwareDecodingName = "DirectX Video Acceleration (DXVA) 2.0";
  264. if (UMPSettings.RuntimePlatform == UMPSettings.Platforms.Mac)
  265. hardwareDecodingName = "Video Decode Acceleration Framework (VDA)";
  266. if (UMPSettings.RuntimePlatform == UMPSettings.Platforms.Linux)
  267. hardwareDecodingName = "VA-API video decoder via DRM";
  268. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", hardwareDecodingName));
  269. }
  270. if (_desktopHardwareDecodingProp.intValue == (int)PlayerOptions.States.Enable)
  271. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Automatic"));
  272. EditorGUILayout.Space();
  273. #endregion
  274. #region Flip Options
  275. _desktopFlipVerticallyProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Flip vertically: ", "Flip video frame vertically when we get it from native library (CPU usage cost)."), _desktopFlipVerticallyProp.boolValue);
  276. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Flip video frame vertically when we get it from native library (CPU usage cost)."));
  277. #endregion
  278. #region Buffer Options
  279. _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);
  280. 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."));
  281. #endregion
  282. #region Dublicate Options
  283. _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);
  284. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Duplicate the output stream and redirect it to a file (output file must have '.mp4' video file format)."));
  285. if (_desktopOutputToFileProp.boolValue)
  286. {
  287. _desktopDisplayOutputProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Display source video: ", "Display source video when duplicate data to a file."), _desktopDisplayOutputProp.boolValue);
  288. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Display source video when duplicate data to a file."));
  289. _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);
  290. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Full path to a file where output data will be stored (example: 'C:\\Path\\To\\File\\Name.mp4')."));
  291. }
  292. EditorGUILayout.Space();
  293. #endregion
  294. #region RTP/RTSP/SDP Options
  295. _desktopRtspOverTcpProp.boolValue = EditorGUILayout.Toggle(new GUIContent("RTP over RTSP (TCP): ", "Use RTP over RTSP (TCP) (HTTP default)."), _desktopRtspOverTcpProp.boolValue);
  296. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use RTP over RTSP (TCP) (HTTP default)."));
  297. #endregion
  298. EditorGUI.EndDisabledGroup();
  299. EditorGUI.BeginDisabledGroup(umpEditor.IsReady);
  300. #region Caching Options
  301. _desktopFileCachingProp.intValue = EditorGUILayout.IntField(new GUIContent("File caching (ms): ", "Caching value for local files, in milliseconds."), _desktopFileCachingProp.intValue);
  302. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for local files, in milliseconds."));
  303. _desktopFileCachingProp.intValue = Mathf.Clamp(_desktopFileCachingProp.intValue, 0, 60000);
  304. _desktopLiveCachingProp.intValue = EditorGUILayout.IntField(new GUIContent("Live capture caching (ms): ", "Caching value for cameras and microphones, in milliseconds."), _desktopLiveCachingProp.intValue);
  305. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for cameras and microphones, in milliseconds."));
  306. _desktopLiveCachingProp.intValue = Mathf.Clamp(_desktopLiveCachingProp.intValue, 0, 60000);
  307. _desktopDiskCachingProp.intValue = EditorGUILayout.IntField(new GUIContent("Disc caching (ms): ", "Caching value for optical media, in milliseconds."), _desktopDiskCachingProp.intValue);
  308. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for optical media, in milliseconds."));
  309. _desktopDiskCachingProp.intValue = Mathf.Clamp(_desktopDiskCachingProp.intValue, 0, 60000);
  310. _desktopNetworkCachingProp.intValue = EditorGUILayout.IntField(new GUIContent("Network caching (ms): ", "Caching value for network resources, in milliseconds."), _desktopNetworkCachingProp.intValue);
  311. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Caching value for network resources, in milliseconds."));
  312. _desktopNetworkCachingProp.intValue = Mathf.Clamp(_desktopNetworkCachingProp.intValue, 0, 60000);
  313. #endregion
  314. EditorGUI.EndDisabledGroup();
  315. }
  316. #endregion
  317. #region WebGL Options
  318. if (_availablePlatforms[_chosenPlatformProp.intValue] == UMPSettings.Platforms.WebGL.ToString())
  319. {
  320. var warningLabel = new GUIStyle(EditorStyles.textArea);
  321. warningLabel.fontStyle = FontStyle.Bold;
  322. EditorGUILayout.LabelField("Doesn't support any additional options for current platform in this version.", warningLabel);
  323. }
  324. #endregion
  325. EditorGUI.BeginDisabledGroup(Application.isPlaying);
  326. #region Android Options
  327. if (_availablePlatforms[_chosenPlatformProp.intValue] == UMPSettings.Platforms.Android.ToString())
  328. {
  329. #region Player Type Options
  330. EditorGUILayout.Space();
  331. var playersNames = new List<string>();
  332. var playerValues = (int[])Enum.GetValues(typeof(PlayerOptionsAndroid.PlayerTypes));
  333. var playerEnum = (PlayerOptionsAndroid.PlayerTypes)_androidPlayerTypeProp.intValue;
  334. var choosedPlayer = -1;
  335. for (int i = 0; i < playerValues.Length; i++)
  336. {
  337. var playerType = (PlayerOptionsAndroid.PlayerTypes)playerValues[i];
  338. if ((settings.PlayersAndroid & playerType) == playerType)
  339. {
  340. playersNames.Add(playerType.ToString());
  341. if (playerEnum == playerType)
  342. choosedPlayer = playersNames.Count - 1;
  343. }
  344. }
  345. if (choosedPlayer < 0)
  346. choosedPlayer = 0;
  347. GUILayout.BeginHorizontal();
  348. EditorGUILayout.LabelField(new GUIContent("Player Type:", "Choose player type for current instance"), GUILayout.Width(80));
  349. EditorGUILayout.Space();
  350. choosedPlayer = GUILayout.SelectionGrid(choosedPlayer, playersNames.ToArray(), playersNames.Count, EditorStyles.miniButton, GUILayout.Width(playersNames.Count * 60));
  351. GUILayout.EndHorizontal();
  352. _androidPlayerTypeProp.intValue = (int)Enum.Parse(typeof(PlayerOptionsAndroid.PlayerTypes), playersNames[choosedPlayer]);
  353. _androidPlayerTypeProp.serializedObject.ApplyModifiedProperties();
  354. EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
  355. #endregion
  356. if (_androidPlayerTypeProp.intValue == (int)PlayerOptionsAndroid.PlayerTypes.LibVLC)
  357. {
  358. #region Hardware Acceleration Options
  359. 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);
  360. if (_androidHardwareAccelerationProp.intValue == (int)PlayerOptionsAndroid.DecodingStates.Disabled)
  361. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Disabled: better stability."));
  362. if (_androidHardwareAccelerationProp.intValue == (int)PlayerOptionsAndroid.DecodingStates.DecodingAcceleration)
  363. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Decoding: may improve performance."));
  364. if (_androidHardwareAccelerationProp.intValue == (int)PlayerOptionsAndroid.DecodingStates.FullAcceleration)
  365. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Full: may improve performance further."));
  366. EditorGUILayout.Space();
  367. #endregion
  368. #region OpenGL Decoding Options
  369. 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);
  370. if (_androidOpenGLDecodingProp.intValue == (int)PlayerOptions.States.Default)
  371. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Automatic."));
  372. if (_androidOpenGLDecodingProp.intValue == (int)PlayerOptions.States.Disable)
  373. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Force Off."));
  374. if (_androidOpenGLDecodingProp.intValue == (int)PlayerOptions.States.Enable)
  375. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Force On."));
  376. EditorGUILayout.Space();
  377. #endregion
  378. #region Video Chroma Options
  379. 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);
  380. if (_androidOpenGLDecodingProp.intValue == (int)PlayerOptionsAndroid.ChromaTypes.RGB32Bit)
  381. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "RGB 32-bit: default chroma."));
  382. if (_androidOpenGLDecodingProp.intValue == (int)PlayerOptionsAndroid.ChromaTypes.RGB16Bit)
  383. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "RGB 16-bit: better performance but lower quality."));
  384. if (_androidOpenGLDecodingProp.intValue == (int)PlayerOptionsAndroid.ChromaTypes.YUV)
  385. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "YUV: best performance but does not work on all devices. Android 2.3 and later only."));
  386. EditorGUILayout.Space();
  387. #endregion
  388. #region Background Options
  389. _androidPlayInBackgroundProb.boolValue = EditorGUILayout.Toggle(new GUIContent("Play in background: ", "Continue play video when application in background."), _androidPlayInBackgroundProb.boolValue);
  390. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Continue play video when application in background."));
  391. #endregion
  392. #region RTP/RTSP/SDP Options
  393. _androidRtspOverTcpProp.boolValue = EditorGUILayout.Toggle(new GUIContent("RTP over RTSP (TCP): ", "Use RTP over RTSP (TCP) (HTTP default)."), _androidRtspOverTcpProp.boolValue);
  394. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use RTP over RTSP (TCP) (HTTP default)."));
  395. #endregion
  396. #region Caching Options
  397. _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);
  398. 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."));
  399. _androidNetworkCachingProp.intValue = Mathf.Clamp(_androidNetworkCachingProp.intValue, 0, 60000);
  400. #endregion
  401. }
  402. else
  403. {
  404. var warningLabel = new GUIStyle(EditorStyles.textArea);
  405. warningLabel.fontStyle = FontStyle.Bold;
  406. EditorGUILayout.LabelField("Doesn't support any additional options for '" + ((PlayerOptionsAndroid.PlayerTypes)_androidPlayerTypeProp.intValue).ToString() + "' player in this version.", warningLabel);
  407. }
  408. }
  409. #endregion
  410. EditorGUI.EndDisabledGroup();
  411. EditorGUI.BeginDisabledGroup(Application.isPlaying);
  412. #region IPhone Options
  413. if (_availablePlatforms[_chosenPlatformProp.intValue] == UMPSettings.Platforms.iOS.ToString())
  414. {
  415. #region Player Type Options
  416. EditorGUILayout.Space();
  417. var playersNames = new List<string>();
  418. var playerValues = (int[])Enum.GetValues(typeof(PlayerOptionsIPhone.PlayerTypes));
  419. var playerEnum = (PlayerOptionsIPhone.PlayerTypes)_iphonePlayerTypeProp.intValue;
  420. var choosedPlayer = -1;
  421. for (int i = 0; i < playerValues.Length; i++)
  422. {
  423. var playerType = (PlayerOptionsIPhone.PlayerTypes)playerValues[i];
  424. if ((settings.PlayersIPhone & playerType) == playerType)
  425. {
  426. playersNames.Add(playerType.ToString());
  427. if (playerEnum == playerType)
  428. choosedPlayer = playersNames.Count - 1;
  429. }
  430. }
  431. if (choosedPlayer < 0)
  432. choosedPlayer = 0;
  433. GUILayout.BeginHorizontal();
  434. EditorGUILayout.LabelField(new GUIContent("Player Type:", "Choose player type for current instance"), GUILayout.Width(80));
  435. EditorGUILayout.Space();
  436. choosedPlayer = GUILayout.SelectionGrid(choosedPlayer, playersNames.ToArray(), playersNames.Count, EditorStyles.miniButton, GUILayout.Width(playersNames.Count * 60));
  437. GUILayout.EndHorizontal();
  438. _iphonePlayerTypeProp.intValue = (int)Enum.Parse(typeof(PlayerOptionsIPhone.PlayerTypes), playersNames[choosedPlayer]);
  439. _iphonePlayerTypeProp.serializedObject.ApplyModifiedProperties();
  440. EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
  441. #endregion
  442. if (_iphonePlayerTypeProp.intValue == (int)PlayerOptionsIPhone.PlayerTypes.FFmpeg)
  443. {
  444. #region VideoToolbox Options
  445. _iphoneVideoToolboxProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Hardware decoding: ", "This allows hardware decoding when available (enable VideoToolbox decoding)."), _iphoneVideoToolboxProp.boolValue);
  446. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "This allows hardware decoding when available (enable VideoToolbox decoding)."));
  447. if (_iphoneVideoToolboxProp.boolValue)
  448. {
  449. _iphoneVideoToolboxMaxFrameWidthProp.intValue = EditorGUILayout.IntField(new GUIContent("Max width of output frame: ", "Max possible video resolution for hardware decoding."), _iphoneVideoToolboxMaxFrameWidthProp.intValue);
  450. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Max possible video resolution for hardware decoding."));
  451. _iphoneVideoToolboxMaxFrameWidthProp.intValue = Mathf.Clamp(_iphoneVideoToolboxMaxFrameWidthProp.intValue, 0, 32768);
  452. _iphoneVideoToolboxAsyncProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Async decompression: ", "Use asynchronous decompression for hardware frame decoding."), _iphoneVideoToolboxAsyncProp.boolValue);
  453. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use asynchronous decompression for hardware frame decoding."));
  454. if (_iphoneVideoToolboxAsyncProp.boolValue)
  455. {
  456. _iphoneVideoToolboxWaitAsyncProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Wait for asynchronous frames: ", "Wait when frames is ready."), _iphoneVideoToolboxWaitAsyncProp.boolValue);
  457. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Wait when frames is ready."));
  458. }
  459. }
  460. EditorGUILayout.Space();
  461. #endregion
  462. #region Background Options
  463. _iphonePlayInBackgroundProb.boolValue = EditorGUILayout.Toggle(new GUIContent("Play in background: ", "Continue play video when application in background."), _iphonePlayInBackgroundProb.boolValue);
  464. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Continue play video when application in background."));
  465. #endregion
  466. #region RTP/RTSP/SDP Options
  467. _iphoneRtspOverTcpProp.boolValue = EditorGUILayout.Toggle(new GUIContent("RTP over RTSP (TCP): ", "Use RTP over RTSP (TCP) (HTTP default)."), _iphoneRtspOverTcpProp.boolValue);
  468. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Use RTP over RTSP (TCP) (HTTP default)."));
  469. #endregion
  470. #region Buffer Options
  471. _iphonePacketBufferingProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Packet buffering: ", "Pause output until enough packets have been read after stalling."), _iphonePacketBufferingProp.boolValue);
  472. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Pause output until enough packets have been read after stalling."));
  473. _iphoneMaxBufferSizeProp.intValue = EditorGUILayout.IntField(new GUIContent("Max buffer size: ", "Max buffer size should be pre-read (in bytes)."), _iphoneMaxBufferSizeProp.intValue);
  474. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Max buffer size should be pre-read."));
  475. _iphoneMaxBufferSizeProp.intValue = Mathf.Clamp(_iphoneMaxBufferSizeProp.intValue, 0, 15 * 1024 * 1024);
  476. _iphoneMinFramesProp.intValue = EditorGUILayout.IntField(new GUIContent("Min frames: ", "Minimal frames to stop pre-reading."), _iphoneMinFramesProp.intValue);
  477. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Minimal frames to stop pre-reading."));
  478. _iphoneMinFramesProp.intValue = Mathf.Clamp(_iphoneMinFramesProp.intValue, 5, 50000);
  479. _iphoneInfbufProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Infbuf: ", "Don't limit the input buffer size (useful with realtime streams)."), _iphoneInfbufProp.boolValue);
  480. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Don't limit the input buffer size (useful with realtime streams)."));
  481. EditorGUILayout.Space();
  482. #endregion
  483. #region Frame Options
  484. _iphoneFramedropProp.intValue = EditorGUILayout.IntField(new GUIContent("Framedrop: ", "Drop frames when cpu is too slow."), _iphoneFramedropProp.intValue);
  485. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Drop frames when cpu is too slow."));
  486. _iphoneFramedropProp.intValue = Mathf.Clamp(_iphoneFramedropProp.intValue, -1, 120);
  487. _iphoneMaxFpsProp.intValue = EditorGUILayout.IntField(new GUIContent("Max fps: ", "Drop frames in video whose fps is greater than max-fps."), _iphoneMaxFpsProp.intValue);
  488. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Drop frames in video whose fps is greater than max-fps."));
  489. _iphoneMaxFpsProp.intValue = Mathf.Clamp(_iphoneMaxFpsProp.intValue, -1, 120);
  490. #endregion
  491. }
  492. else if (_iphonePlayerTypeProp.intValue == (int)PlayerOptionsIPhone.PlayerTypes.Native)
  493. {
  494. #region Flip Options
  495. _iphoneFlipVerticallyProp.boolValue = EditorGUILayout.Toggle(new GUIContent("Flip vertically: ", "Flip video frame vertically when we get it from native library (CPU usage cost)."), _iphoneFlipVerticallyProp.boolValue);
  496. GUI.Label(GUILayoutUtility.GetLastRect(), new GUIContent("", "Flip video frame vertically when we get it from native library (CPU usage cost)."));
  497. #endregion
  498. }
  499. else
  500. {
  501. var warningLabel = new GUIStyle(EditorStyles.textArea);
  502. warningLabel.fontStyle = FontStyle.Bold;
  503. EditorGUILayout.LabelField("Doesn't support any additional options for '" + ((PlayerOptionsAndroid.PlayerTypes)_iphonePlayerTypeProp.intValue).ToString() + "' player in this version.", warningLabel);
  504. }
  505. }
  506. #endregion
  507. EditorGUI.EndDisabledGroup();
  508. EditorGUIUtility.labelWidth = _cachedLabelWidth;
  509. }
  510. else
  511. {
  512. _desktopFileCachingProp.intValue = PlayerOptions.DEFAULT_CACHING_VALUE;
  513. _desktopLiveCachingProp.intValue = PlayerOptions.DEFAULT_CACHING_VALUE;
  514. _desktopDiskCachingProp.intValue = PlayerOptions.DEFAULT_CACHING_VALUE;
  515. _desktopNetworkCachingProp.intValue = PlayerOptions.DEFAULT_CACHING_VALUE;
  516. _fixedVideoWidthProp.intValue = -1;
  517. _fixedVideoHeightProp.intValue = -1;
  518. }
  519. if (settings.UseExternalLibraries)
  520. {
  521. if (_externalPath.Equals(string.Empty))
  522. _externalPath = settings.GetLibrariesPath(UMPSettings.RuntimePlatform, true);
  523. if (_externalPath != string.Empty)
  524. {
  525. var wrapTextStyle = EditorStyles.textArea;
  526. wrapTextStyle.wordWrap = true;
  527. EditorGUILayout.LabelField("Path to external/installed libraries: '" + _externalPath + "'", wrapTextStyle);
  528. }
  529. }
  530. else
  531. {
  532. _externalPath = string.Empty;
  533. }
  534. GUILayout.EndVertical();
  535. #endregion
  536. #region Player Fields
  537. EditorGUILayout.Space();
  538. EditorStyles.label.fontStyle = FontStyle.Bold;
  539. EditorGUILayout.LabelField("Player properties:");
  540. EditorStyles.label.fontStyle = _cachedFontStyle;
  541. GUILayout.BeginHorizontal();
  542. GUILayout.BeginVertical("Box");
  543. GUILayout.BeginHorizontal();
  544. var centeredStyle = GUI.skin.GetStyle("Label");
  545. centeredStyle.alignment = TextAnchor.MiddleCenter;
  546. EditorGUILayout.LabelField("Volume", centeredStyle, GUILayout.MinWidth(80));
  547. if (GUILayout.Button("x", EditorStyles.miniButton))
  548. {
  549. _volumeProp.intValue = 50;
  550. }
  551. GUILayout.EndHorizontal();
  552. _volumeProp.intValue = EditorGUILayout.IntSlider(_volumeProp.intValue, 0, 100);
  553. GUILayout.EndVertical();
  554. GUILayout.BeginVertical("Box");
  555. GUILayout.BeginHorizontal();
  556. EditorGUILayout.LabelField("Play rate", centeredStyle, GUILayout.MinWidth(80));
  557. if (GUILayout.Button("x", EditorStyles.miniButton))
  558. {
  559. _playRateProp.floatValue = 1f;
  560. }
  561. GUILayout.EndHorizontal();
  562. _playRateProp.floatValue = EditorGUILayout.Slider(_playRateProp.floatValue, 0.5f, 5f);
  563. GUILayout.EndVertical();
  564. GUILayout.EndHorizontal();
  565. EditorGUI.BeginDisabledGroup(!umpEditor.IsReady);
  566. EditorGUILayout.Space();
  567. GUILayout.BeginVertical("Box");
  568. EditorGUILayout.LabelField("Position", centeredStyle, GUILayout.MinWidth(100));
  569. _positionProp.floatValue = EditorGUILayout.Slider(_positionProp.floatValue, 0f, 1f);
  570. GUILayout.EndVertical();
  571. EditorGUI.EndDisabledGroup();
  572. EditorGUI.BeginDisabledGroup(!Application.isPlaying || !umpEditor.isActiveAndEnabled || umpEditor.IsParsing);
  573. GUILayout.BeginHorizontal("Box");
  574. if (GUILayout.Button("LOAD", GUILayout.MinWidth(40)))
  575. {
  576. umpEditor.Prepare();
  577. }
  578. if (GUILayout.Button("PLAY", GUILayout.MinWidth(40)))
  579. {
  580. umpEditor.Play();
  581. }
  582. if (GUILayout.Button("PAUSE", GUILayout.MinWidth(40)))
  583. {
  584. umpEditor.Pause();
  585. }
  586. if (GUILayout.Button("STOP", GUILayout.MinWidth(40)))
  587. {
  588. umpEditor.Stop();
  589. }
  590. if (GUILayout.Button("SHOT", GUILayout.MinWidth(40)))
  591. {
  592. umpEditor.Snapshot(Application.persistentDataPath);
  593. }
  594. GUILayout.EndHorizontal();
  595. EditorGUI.EndDisabledGroup();
  596. #endregion
  597. #region Events & Logging Fields
  598. EditorGUILayout.Space();
  599. EditorStyles.label.fontStyle = FontStyle.Bold;
  600. EditorGUILayout.LabelField("Events & Logging:");
  601. EditorStyles.label.fontStyle = _cachedFontStyle;
  602. GUILayout.BeginVertical("Box");
  603. EditorGUI.BeginDisabledGroup(Application.isPlaying);
  604. EditorGUILayout.PropertyField(_logDetailProp, GUILayout.MinWidth(50));
  605. EditorGUI.EndDisabledGroup();
  606. GUILayout.BeginHorizontal();
  607. EditorGUILayout.LabelField("Last msg: ", GUILayout.MinWidth(70));
  608. EditorStyles.label.normal.textColor = Color.black;
  609. EditorStyles.label.fontStyle = FontStyle.Italic;
  610. EditorStyles.label.wordWrap = true;
  611. EditorGUILayout.LabelField(_lastEventMsgProp.stringValue, GUILayout.MaxWidth(100));
  612. EditorStyles.label.normal.textColor = _cachedTextColor;
  613. EditorStyles.label.fontStyle = _cachedFontStyle;
  614. EditorStyles.label.wordWrap = _cachedLabelWordWrap;
  615. GUILayout.EndHorizontal();
  616. GUILayout.EndVertical();
  617. _showEventsListeners = EditorGUILayout.Foldout(_showEventsListeners, "Event Listeners");
  618. if (_showEventsListeners)
  619. {
  620. EditorGUILayout.PropertyField(_pathPreparedEventProp, new GUIContent("Path Prepared"), true, GUILayout.MinWidth(50));
  621. EditorGUILayout.PropertyField(_openingEventProp, new GUIContent("Opening"), true, GUILayout.MinWidth(50));
  622. EditorGUILayout.PropertyField(_bufferingEventProp, new GUIContent("Buffering"), true, GUILayout.MinWidth(50));
  623. EditorGUILayout.PropertyField(_imageReadyEventProp, new GUIContent("ImageReady"), true, GUILayout.MinWidth(50));
  624. EditorGUILayout.PropertyField(_preparedEventProp, new GUIContent("Prepared"), true, GUILayout.MinWidth(50));
  625. EditorGUILayout.PropertyField(_playingEventProp, new GUIContent("Playing"), true, GUILayout.MinWidth(50));
  626. EditorGUILayout.PropertyField(_pausedEventProp, new GUIContent("Paused"), true, GUILayout.MinWidth(50));
  627. EditorGUILayout.PropertyField(_stoppedEventProp, new GUIContent("Stopped"), true, GUILayout.MinWidth(50));
  628. EditorGUILayout.PropertyField(_endReachedEventProp, new GUIContent("End Reached"), true, GUILayout.MinWidth(50));
  629. EditorGUILayout.PropertyField(_encounteredErrorEventProp, new GUIContent("Encountered Error"), true, GUILayout.MinWidth(50));
  630. EditorGUILayout.PropertyField(_timeChangedEventProp, new GUIContent("Time Changed"), true, GUILayout.MinWidth(50));
  631. EditorGUILayout.PropertyField(_positionChangedEventProp, new GUIContent("Position Changed"), true, GUILayout.MinWidth(50));
  632. EditorGUILayout.PropertyField(_snapshotTakenEventProp, new GUIContent("Snapshot"), true, GUILayout.MinWidth(50));
  633. }
  634. #endregion
  635. EditorStyles.label.normal.textColor = _cachedTextColor;
  636. EditorStyles.label.fontStyle = _cachedFontStyle;
  637. if (EditorGUI.EndChangeCheck())
  638. serializedObject.ApplyModifiedProperties();
  639. }
  640. }