SupportWindow.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. 
  2. using UnityEngine;
  3. using UnityEditor;
  4. using System.Text;
  5. using System.IO;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System;
  9. //-----------------------------------------------------------------------------
  10. // Copyright 2016-2021 RenderHeads Ltd. All rights reserved.
  11. //-----------------------------------------------------------------------------
  12. namespace RenderHeads.Media.AVProVideo.Editor
  13. {
  14. /// <summary>
  15. /// A window to display options to the user to help them report bugs
  16. /// Also collects some metadata about the machine specs, plugin version etc
  17. /// </summary>
  18. public class SupportWindow : EditorWindow
  19. {
  20. private class MyPopupWindow : PopupWindowContent
  21. {
  22. private string _text;
  23. private string _url;
  24. private string _buttonMessage;
  25. public MyPopupWindow(string text, string buttonMessage,string url)
  26. {
  27. _text = text;
  28. _url = url;
  29. _buttonMessage = buttonMessage;
  30. }
  31. public override Vector2 GetWindowSize()
  32. {
  33. return new Vector2(400, 520);
  34. }
  35. public override void OnGUI(Rect rect)
  36. {
  37. GUILayout.BeginHorizontal();
  38. GUILayout.Label("Copy-Paste this text, then ", EditorStyles.boldLabel);
  39. GUI.color = Color.green;
  40. if (GUILayout.Button(_buttonMessage, GUILayout.ExpandWidth(true)))
  41. {
  42. Application.OpenURL(_url);
  43. }
  44. GUILayout.EndHorizontal();
  45. GUI.color = Color.white;
  46. EditorGUILayout.TextArea(_text);
  47. }
  48. }
  49. private static bool _isCreated = false;
  50. private static bool _isInit = false;
  51. private const string SettingsPrefix = "AVProVideo.SupportWindow.";
  52. private string _emailDescription = string.Empty;
  53. private string _emailTopic = string.Empty;
  54. private string _emailVideoFormat = string.Empty;
  55. private string _emailDeviceSpecs = string.Empty;
  56. //private bool _askForHelp = false;
  57. private bool _trySelfSolve = false;
  58. private Vector2 _scroll = Vector2.zero;
  59. private int _selectionIndex = 0;
  60. private static string[] _gridNames = { "Help Resources", "Ask for Help", "Update v2.x to v3.x" };
  61. [MenuItem("Window/AVPro Video Support")]
  62. public static void Init()
  63. {
  64. // Close window if it is already open
  65. if (_isInit || _isCreated)
  66. {
  67. SupportWindow window = (SupportWindow)EditorWindow.GetWindow(typeof(SupportWindow));
  68. window.Close();
  69. return;
  70. }
  71. _isCreated = true;
  72. // Get existing open window or if none, make a new one:
  73. SupportWindow window2 = ScriptableObject.CreateInstance<SupportWindow>();
  74. if (window2 != null)
  75. {
  76. window2.SetupWindow();
  77. }
  78. }
  79. private void SetupWindow()
  80. {
  81. _isCreated = true;
  82. float width = 512f;
  83. float height = 512f;
  84. this.position = new Rect((Screen.width / 2) - (width / 2f), (Screen.height / 2) - (height / 2f), width, height);
  85. this.minSize = new Vector2(530f, 510f);
  86. this.titleContent = new GUIContent("AVPro Video - Help & Support");
  87. this.CreateGUI();
  88. LoadSettings();
  89. this.ShowUtility();
  90. this.Repaint();
  91. }
  92. private void CreateGUI()
  93. {
  94. _isInit = true;
  95. }
  96. void OnEnable()
  97. {
  98. if (!_isCreated)
  99. {
  100. SetupWindow();
  101. }
  102. }
  103. void OnDisable()
  104. {
  105. _isInit = false;
  106. _isCreated = false;
  107. SaveSettings();
  108. Repaint();
  109. }
  110. private void SaveSettings()
  111. {
  112. EditorPrefs.SetString(SettingsPrefix + "EmailTopic", _emailTopic);
  113. EditorPrefs.SetString(SettingsPrefix + "EmailDescription", _emailDescription);
  114. EditorPrefs.SetString(SettingsPrefix + "EmailDeviceSpecs", _emailDeviceSpecs);
  115. EditorPrefs.SetString(SettingsPrefix + "EmailVideoSpecs", _emailVideoFormat);
  116. EditorPrefs.SetBool(SettingsPrefix + "ExpandSelfSolve", _trySelfSolve);
  117. EditorPrefs.SetInt(SettingsPrefix + "SelectionIndex", _selectionIndex);
  118. }
  119. private void LoadSettings()
  120. {
  121. _emailTopic = EditorPrefs.GetString(SettingsPrefix + "EmailTopic", _emailTopic);
  122. _emailDescription = EditorPrefs.GetString(SettingsPrefix + "EmailDescription", _emailDescription);
  123. _emailDeviceSpecs = EditorPrefs.GetString(SettingsPrefix + "EmailDeviceSpecs", _emailDeviceSpecs);
  124. _emailVideoFormat = EditorPrefs.GetString(SettingsPrefix + "EmailVideoSpecs", _emailVideoFormat);
  125. _trySelfSolve = EditorPrefs.GetBool(SettingsPrefix + "ExpandSelfSolve", _trySelfSolve);
  126. _selectionIndex = EditorPrefs.GetInt(SettingsPrefix + "SelectionIndex", _selectionIndex);
  127. }
  128. private string CollectSupportData()
  129. {
  130. string nl = System.Environment.NewLine;
  131. string version = string.Format("AVPro Video: v{0} (plugin v{1})", Helper.AVProVideoVersion, GetPluginVersion());
  132. string targetPlatform = "Target Platform: " + EditorUserBuildSettings.selectedBuildTargetGroup.ToString();
  133. string unityVersion = "Unity: v" + Application.unityVersion + " " + Application.platform.ToString();
  134. string deviceInfo = "OS: " + SystemInfo.deviceType + " - " + SystemInfo.deviceModel + " - " + SystemInfo.operatingSystem + " - " + Application.systemLanguage;
  135. string cpuInfo = "CPU: " + SystemInfo.processorType + " - " + SystemInfo.processorCount + " threads - " + + SystemInfo.systemMemorySize + "KB";
  136. string gfxInfo = "GPU: " + SystemInfo.graphicsDeviceName + " - " + SystemInfo.graphicsDeviceVendor + " - " + SystemInfo.graphicsDeviceVersion + " - " + SystemInfo.graphicsMemorySize + "KB - " + SystemInfo.maxTextureSize;
  137. return version + nl + targetPlatform + nl + unityVersion + nl + deviceInfo + nl + cpuInfo + nl + gfxInfo;
  138. }
  139. void OnGUI()
  140. {
  141. if (!_isInit)
  142. {
  143. EditorGUILayout.LabelField("Initialising...");
  144. return;
  145. }
  146. GUILayout.Label("Having problems? We'll do our best to help.\n\nBelow is a collection of resources to help solve any issues you may encounter.", EditorStyles.wordWrappedLabel);
  147. GUILayout.Space(16f);
  148. /*GUI.color = Color.white;
  149. GUI.backgroundColor = Color.clear;
  150. if (_trySelfSolve)
  151. {
  152. GUI.color = Color.white;
  153. GUI.backgroundColor = new Color(0.8f, 0.8f, 0.8f, 0.1f);
  154. if (EditorGUIUtility.isProSkin)
  155. {
  156. GUI.backgroundColor = Color.black;
  157. }
  158. }
  159. GUILayout.BeginVertical("box");
  160. GUI.backgroundColor = Color.white;*/
  161. _selectionIndex = GUILayout.Toolbar(_selectionIndex, _gridNames);
  162. GUILayout.Space(16f);
  163. /*if (GUILayout.Button("Try Solve the Issue Yourself", EditorStyles.toolbarButton))
  164. {
  165. //_trySelfSolve = !_trySelfSolve;
  166. _trySelfSolve = true;
  167. }
  168. GUI.color = Color.white;
  169. if (_trySelfSolve)*/
  170. if (_selectionIndex == 0)
  171. {
  172. GUILayout.BeginHorizontal();
  173. GUILayout.Label("1) ");
  174. GUILayout.Label("Check you're using the latest version of AVPro Video via the Asset Store. This is version " + Helper.AVProVideoVersion, EditorStyles.wordWrappedLabel);
  175. GUILayout.FlexibleSpace();
  176. GUILayout.EndHorizontal();
  177. GUILayout.BeginHorizontal();
  178. GUILayout.Label("2) ");
  179. GUILayout.Label("Look at the example projects and scripts in the Demos folder");
  180. GUILayout.FlexibleSpace();
  181. GUILayout.EndHorizontal();
  182. GUILayout.BeginHorizontal();
  183. GUILayout.Label("3) ");
  184. GUI.color = Color.green;
  185. if (GUILayout.Button("Read the Documentation", GUILayout.ExpandWidth(false)))
  186. {
  187. Application.OpenURL(MediaPlayerEditor.LinkUserManual);
  188. }
  189. GUI.color = Color.white;
  190. GUILayout.FlexibleSpace();
  191. GUILayout.EndHorizontal();
  192. GUILayout.BeginHorizontal();
  193. GUILayout.Label("4) ");
  194. GUI.color = Color.green;
  195. if (GUILayout.Button("Read the GitHub Issues", GUILayout.ExpandWidth(false)))
  196. {
  197. Application.OpenURL(MediaPlayerEditor.LinkGithubIssues);
  198. }
  199. GUI.color = Color.white;
  200. GUILayout.FlexibleSpace();
  201. GUILayout.EndHorizontal();
  202. GUILayout.BeginHorizontal();
  203. GUILayout.Label("5) ");
  204. GUI.color = Color.green;
  205. if (GUILayout.Button("Read the Scripting Reference", GUILayout.ExpandWidth(false)))
  206. {
  207. Application.OpenURL(MediaPlayerEditor.LinkScriptingClassReference);
  208. }
  209. GUI.color = Color.white;
  210. GUILayout.FlexibleSpace();
  211. GUILayout.EndHorizontal();
  212. GUILayout.BeginHorizontal();
  213. GUILayout.Label("6) ");
  214. GUI.color = Color.green;
  215. if (GUILayout.Button("Visit the AVPro Video Website", GUILayout.ExpandWidth(false)))
  216. {
  217. Application.OpenURL(MediaPlayerEditor.LinkPluginWebsite);
  218. }
  219. GUI.color = Color.white;
  220. GUILayout.FlexibleSpace();
  221. GUILayout.EndHorizontal();
  222. GUILayout.BeginHorizontal();
  223. GUILayout.Label("7) ");
  224. GUI.color = Color.green;
  225. if (GUILayout.Button("Browse the Unity Forum", GUILayout.ExpandWidth(false)))
  226. {
  227. Application.OpenURL(MediaPlayerEditor.LinkForumPage);
  228. }
  229. GUI.color = Color.white;
  230. GUILayout.FlexibleSpace();
  231. GUILayout.EndHorizontal();
  232. }
  233. else if (_selectionIndex == 1)
  234. {
  235. GUILayout.Label("Please fill out these fields when sending us a new issue.\nThis makes it much easier and faster to resolve the issue.", EditorStyles.wordWrappedLabel);
  236. GUILayout.Space(16f);
  237. GUILayout.BeginVertical("box");
  238. _scroll = GUILayout.BeginScrollView(_scroll);
  239. GUILayout.Label("Issue/Question Title", EditorStyles.boldLabel);
  240. _emailTopic = GUILayout.TextField(_emailTopic);
  241. GUILayout.Space(8f);
  242. GUILayout.Label("What's the problem?", EditorStyles.boldLabel);
  243. _emailDescription = EditorGUILayout.TextArea(_emailDescription, GUILayout.Height(64f));
  244. GUILayout.Space(8f);
  245. GUILayout.BeginHorizontal();
  246. GUILayout.Label("Tell us about your videos", EditorStyles.boldLabel);
  247. GUILayout.Label("- Number of videos, resolution, codec, frame-rate, example URLs", EditorStyles.miniBoldLabel);
  248. GUILayout.FlexibleSpace();
  249. GUILayout.EndHorizontal();
  250. _emailVideoFormat = EditorGUILayout.TextArea(_emailVideoFormat, GUILayout.Height(32f));
  251. GUILayout.Space(8f);
  252. GUILayout.BeginHorizontal();
  253. GUILayout.Label("Which devices are you having the issue with?", EditorStyles.boldLabel);
  254. GUILayout.Label("- Model, OS version number", EditorStyles.miniBoldLabel);
  255. GUILayout.FlexibleSpace();
  256. GUILayout.EndHorizontal();
  257. _emailDeviceSpecs = EditorGUILayout.TextField(_emailDeviceSpecs);
  258. //GUILayout.Space(16f);
  259. ////GUILayout.Label("System Information");
  260. //GUILayout.TextArea(CollectSupportData());
  261. string emailBody = System.Environment.NewLine + System.Environment.NewLine;
  262. emailBody += "Problem description:" + System.Environment.NewLine + System.Environment.NewLine + _emailDescription + System.Environment.NewLine + System.Environment.NewLine;
  263. emailBody += "Device (which devices are you having the issue with - model, OS version number):" + System.Environment.NewLine + System.Environment.NewLine + _emailDeviceSpecs + System.Environment.NewLine + System.Environment.NewLine;
  264. emailBody += "Media (tell us about your videos - number of videos, resolution, codec, frame-rate, example URLs):" + System.Environment.NewLine + System.Environment.NewLine + _emailVideoFormat + System.Environment.NewLine + System.Environment.NewLine;
  265. emailBody += "System Information:" + System.Environment.NewLine + System.Environment.NewLine + CollectSupportData() + System.Environment.NewLine + System.Environment.NewLine;
  266. //GUILayout.Space(16f);
  267. //
  268. //GUILayout.Label("Email Content");
  269. //EditorGUILayout.TextArea(emailBody);
  270. GUILayout.EndScrollView();
  271. GUILayout.EndVertical();
  272. GUILayout.Space(16f);
  273. GUILayout.BeginHorizontal();
  274. GUILayout.FlexibleSpace();
  275. GUI.color = Color.green;
  276. if (GUILayout.Button("Send at GitHub Issues ➔", GUILayout.ExpandWidth(false), GUILayout.Height(32f)))
  277. {
  278. PopupWindow.Show(buttonRect, new MyPopupWindow(emailBody, "Go to GitHub", MediaPlayerEditor.LinkGithubIssuesNew));
  279. }
  280. /*if (GUILayout.Button("Send at the Unity Forum ➔", GUILayout.ExpandWidth(false), GUILayout.Height(32f)))
  281. {
  282. PopupWindow.Show(buttonRect, new MyPopupWindow(emailBody, "Go to Forum", MediaPlayerEditor.LinkForumLastPage));
  283. }*/
  284. if (Event.current.type == EventType.Repaint)
  285. {
  286. buttonRect = GUILayoutUtility.GetLastRect();
  287. }
  288. GUI.color = Color.white;
  289. GUILayout.FlexibleSpace();
  290. GUILayout.EndHorizontal();
  291. }
  292. else if (_selectionIndex == 2)
  293. {
  294. GUILayout.Label("There are a number of files/folders that need to be removed going from AVPro Video version 2.x to AVPro Video v3.x in order for v3.x to build and run correctly.\n\nIn order to complete a smooth upgrade a project using AVPro Video v2.x to v3.x please follow the following steps:", EditorStyles.wordWrappedLabel);
  295. GUILayout.Space(16f);
  296. GUILayout.BeginHorizontal();
  297. GUILayout.Label("1) Import the latest AVPro Video v3.x asset bundle into a project that already contains AVPro Video v2.x", EditorStyles.wordWrappedLabel);
  298. GUILayout.FlexibleSpace();
  299. GUILayout.EndHorizontal();
  300. GUILayout.BeginHorizontal();
  301. GUILayout.Label("2) Click the update button");
  302. if (GUILayout.Button("Update", GUILayout.ExpandWidth(true)))
  303. {
  304. List<SFileToDelete> aFilesToDelete = new List<SFileToDelete>();
  305. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Plugins/Android/exoplayer.aar", "d04cd71ba09f0a548ac774e50236a6f7", false) );
  306. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Plugins/Android/exoplayer-common.aar", "782210c1836944347b3b8315635ef044", false) );
  307. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Plugins/Android/exoplayer-container.aar", "2232bec870b56e04aa0107d97204456e", false) );
  308. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Plugins/Android/exoplayer-core.aar", "782210c1836944347b3b8315658ef044", false) );
  309. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Plugins/Android/exoplayer-dash.aar", "d06cd71ba09f0a548ac774e50236a6f7", false) );
  310. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Plugins/Android/exoplayer-database.aar", "a35ee71df09a0a348ac774e75237a6a1", false) );
  311. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Plugins/Android/exoplayer-datasource.aar", "d06cd71df09a0a348ac774e75237a6a1", false) );
  312. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Plugins/Android/exoplayer-decoder.aar", "d06cd71ba09f0a548ac774e75236a6a1", false) );
  313. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Plugins/Android/exoplayer-extractor.aar", "782210c2926744347b3b8315658ef044", false) );
  314. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Plugins/Android/exoplayer-hls.aar", "d07cd71ba09f0a548ac774e50236a6f7", false) );
  315. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Plugins/Android/exoplayer-rtsp.aar", "782210a1816945347b3b8315658ef052", false) );
  316. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Plugins/Android/exoplayer-smoothstreaming.aar", "d08cd71ba09f0a548ac774e50236a6f7", false) );
  317. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Plugins/Android/extension-rtmp.aar", "782210c1836944347b3b8315658ef041", false) );
  318. //
  319. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Plugins/iOS/AVProVideo.framework", "2a1facf97326449499b63c03811b1ab2", true) );
  320. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Plugins/iOS/AVProVideoBootstrap.m", "4df32662530a57c4f83b79e6313690dc", false) );
  321. //
  322. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Plugins/tvOS/AVProVideo.framework", "bcf659e3a94d748d6a100d5531540d1a", true) );
  323. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Plugins/tvOS/AVProVideoBootstrap.m", "154f23675acd6c54e8667de25ac31b67", false) );
  324. //
  325. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Scripts/Internal/Players/AndroidMediaPlayer.cs", "80eb525dd677aa440823910b09b23ae0", false) );
  326. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Scripts/Internal/Players/AppleMediaPlayer.cs", "3f68628a1ef6349648e502d1c66b5114", false) );
  327. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Scripts/Internal/Players/AppleMediaPlayer+Native.cs", "0bf374b5848b649e6b3840fe1dc03cd2", false) );
  328. aFilesToDelete.Add( new SFileToDelete( "Assets/AVProVideo/Runtime/Scripts/Internal/Players/AppleMediaPlayerExtensions.cs", "e27ea5523e11f44c09e8d368eb1f2983", false) );
  329. int iNumberFilesDeleted = DeleteFiles_V2_To_V3(aFilesToDelete, new[] { ".aar", ".m", ".cs" } );
  330. EditorUtility.DisplayDialog("Complete", "Update from AVPro Video v2.x to v3.x is complete.\n\n" + iNumberFilesDeleted + " files/folders were removed in the process", "ok");
  331. }
  332. GUI.color = Color.white;
  333. GUILayout.FlexibleSpace();
  334. GUILayout.EndHorizontal();
  335. }
  336. //GUILayout.EndVertical();
  337. GUILayout.FlexibleSpace();
  338. if (GUILayout.Button("Close"))
  339. {
  340. this.Close();
  341. }
  342. }
  343. private class SFileToDelete
  344. {
  345. public SFileToDelete( string filename, string guid, bool bDirectory )
  346. {
  347. m_Filename = filename;
  348. m_guid = guid;
  349. m_FullPath = null;
  350. m_bIsDirectory = bDirectory;
  351. }
  352. public string m_Filename;
  353. public string m_guid;
  354. public string m_FullPath;
  355. public bool m_bIsDirectory;
  356. };
  357. private int DeleteFiles_V2_To_V3( List<SFileToDelete> aFilesToDelete, string[] allowedExtensions )
  358. {
  359. int iNumRemoved = 0;
  360. try
  361. {
  362. // Folders first
  363. IEnumerable<string> aAllFoders = Directory.GetDirectories( Application.dataPath, "*", SearchOption.AllDirectories );
  364. foreach( string directoryPath in aAllFoders )
  365. {
  366. Uri relativeDirectory = (new Uri(Application.dataPath)).MakeRelativeUri(new Uri(directoryPath));
  367. UnityEngine.Object asssetObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>( relativeDirectory.ToString() );
  368. if(asssetObject)
  369. {
  370. string guid;
  371. long file;
  372. if( AssetDatabase.TryGetGUIDAndLocalFileIdentifier( asssetObject, out guid, out file ) )
  373. {
  374. // Is this a file we want to delete?
  375. foreach( SFileToDelete sFileToDelete in aFilesToDelete )
  376. {
  377. if( !string.IsNullOrEmpty( sFileToDelete.m_guid ) &&
  378. sFileToDelete.m_bIsDirectory &&
  379. sFileToDelete.m_guid.Equals( guid ) )
  380. {
  381. // A hit, delete
  382. Directory.Delete( directoryPath, true );
  383. File.Delete( directoryPath + ".meta" );
  384. iNumRemoved += 2;
  385. }
  386. }
  387. }
  388. }
  389. }
  390. // Files
  391. IEnumerable<string> aAllFiles = Directory.GetFiles( Application.dataPath, "*.*", SearchOption.AllDirectories ).Where(file => allowedExtensions.Any(file.ToLower().EndsWith));
  392. foreach( string filePath in aAllFiles )
  393. {
  394. Uri relativeFilename = (new Uri(Application.dataPath)).MakeRelativeUri(new Uri(filePath));
  395. UnityEngine.Object asssetObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>( relativeFilename.ToString() );
  396. if(asssetObject)
  397. {
  398. string guid;
  399. long file;
  400. if( AssetDatabase.TryGetGUIDAndLocalFileIdentifier( asssetObject, out guid, out file ) )
  401. {
  402. // Is this a file we want to delete?
  403. foreach( SFileToDelete sFileToDelete in aFilesToDelete )
  404. {
  405. if( !string.IsNullOrEmpty( sFileToDelete.m_guid ) &&
  406. !sFileToDelete.m_bIsDirectory &&
  407. sFileToDelete.m_guid.Equals( guid ) )
  408. {
  409. // A hit, delete
  410. File.Delete( filePath );
  411. File.Delete( filePath + ".meta" );
  412. iNumRemoved += 2;
  413. }
  414. }
  415. }
  416. }
  417. }
  418. }
  419. catch (UnauthorizedAccessException UAEx)
  420. {
  421. Console.WriteLine(UAEx.Message);
  422. }
  423. catch (PathTooLongException PathEx)
  424. {
  425. Console.WriteLine(PathEx.Message);
  426. }
  427. return iNumRemoved;
  428. }
  429. private Rect buttonRect;
  430. private struct Native
  431. {
  432. #if UNITY_EDITOR_WIN
  433. [System.Runtime.InteropServices.DllImport("AVProVideo")]
  434. public static extern System.IntPtr GetPluginVersion();
  435. #elif UNITY_EDITOR_OSX
  436. [System.Runtime.InteropServices.DllImport("AVProVideo")]
  437. public static extern string AVPGetVersion();
  438. #endif
  439. }
  440. private static string GetPluginVersion()
  441. {
  442. string version = "Unknown";
  443. try
  444. {
  445. #if UNITY_EDITOR_WIN
  446. version = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(Native.GetPluginVersion());
  447. #elif UNITY_EDITOR_OSX
  448. version = Native.AVPGetVersion();
  449. #endif
  450. }
  451. catch (System.DllNotFoundException e)
  452. {
  453. Debug.LogError("[AVProVideo] Failed to load DLL. " + e.Message);
  454. }
  455. return version;
  456. }
  457. }
  458. }