ASEStartScreen.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. // Amplify Shader Editor - Visual Shader Editing Tool
  2. // Copyright (c) Amplify Creations, Lda <info@amplify.pt>
  3. using UnityEngine;
  4. using UnityEditor;
  5. using System;
  6. using UnityEngine.Networking;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. namespace AmplifyShaderEditor
  10. {
  11. public class ASEStartScreen : EditorWindow
  12. {
  13. [MenuItem( "Window/Amplify Shader Editor/Start Screen", false, 1999 )]
  14. public static void Init()
  15. {
  16. ASEStartScreen window = (ASEStartScreen)GetWindow( typeof( ASEStartScreen ), true, "Amplify Shader Editor Start Screen" );
  17. window.minSize = new Vector2( 650, 500 );
  18. window.maxSize = new Vector2( 650, 500 );
  19. window.Show();
  20. }
  21. private static readonly string ChangeLogGUID = "580cccd3e608b7f4cac35ea46d62d429";
  22. private static readonly string ResourcesGUID = "c0a0a980c9ba86345bc15411db88d34f";
  23. private static readonly string BuiltInGUID = "e00e6f90ab8233e46a41c5e33917c642";
  24. private static readonly string UniversalGUID = "a9d68dd8913f05d4d9ce75e7b40c6044";
  25. private static readonly string HighDefinitionGUID = "d1c0b77896049554fa4b635531caf741";
  26. private static readonly string IconGUID = "2c6536772776dd84f872779990273bfc";
  27. public static readonly string ChangelogURL = "https://amplify.pt/Banner/ASEchangelog.json";
  28. private static readonly string ManualURL = "https://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Manual";
  29. private static readonly string BasicURL = "https://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Tutorials#Official_-_Basics";
  30. private static readonly string BeginnerURL = "https://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Tutorials#Official_-_Beginner_Series";
  31. private static readonly string NodesURL = "https://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Nodes";
  32. private static readonly string SRPURL = "https://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Scriptable_Rendering_Pipeline";
  33. private static readonly string FunctionsURL = "https://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Manual#Shader_Functions";
  34. private static readonly string TemplatesURL = "https://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Templates";
  35. private static readonly string APIURL = "https://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/API";
  36. private static readonly string SGtoASEURL = "https://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Shader_Graph_to_ASE";
  37. private static readonly string DiscordURL = "https://discordapp.com/invite/EdrVAP5";
  38. private static readonly string ForumURL = "https://forum.unity.com/threads/best-tool-asset-store-award-amplify-shader-editor-node-based-shader-creation-tool.430959/";
  39. private static readonly string SiteURL = "http://amplify.pt/download/";
  40. private static readonly string StoreURL = "https://assetstore.unity.com/packages/tools/visual-scripting/amplify-shader-editor-68570";
  41. private static readonly GUIContent SamplesTitle = new GUIContent( "Shader Samples", "Import samples according to you project rendering pipeline" );
  42. private static readonly GUIContent ResourcesTitle = new GUIContent( "Learning Resources", "Check the online wiki for various topics about how to use ASE with node examples and explanations" );
  43. private static readonly GUIContent CommunityTitle = new GUIContent( "Community", "Need help? Reach us through our discord server or the official support Unity forum" );
  44. private static readonly GUIContent UpdateTitle = new GUIContent( "Latest Update", "Check the lastest additions, improvements and bug fixes done to ASE" );
  45. private static readonly GUIContent ASETitle = new GUIContent( "Amplify Shader Editor", "Are you using the latest version? Now you know" );
  46. private const string OnlineVersionWarning = "Please enable \"Allow downloads over HTTP*\" in Player Settings to access latest version information via Start Screen.";
  47. Vector2 m_scrollPosition = Vector2.zero;
  48. Preferences.ShowOption m_startup = Preferences.ShowOption.Never;
  49. [NonSerialized]
  50. Texture packageIcon = null;
  51. [NonSerialized]
  52. Texture textIcon = null;
  53. [NonSerialized]
  54. Texture webIcon = null;
  55. GUIContent HDRPbutton = null;
  56. GUIContent URPbutton = null;
  57. GUIContent BuiltInbutton = null;
  58. GUIContent Manualbutton = null;
  59. GUIContent Basicbutton = null;
  60. GUIContent Beginnerbutton = null;
  61. GUIContent Nodesbutton = null;
  62. GUIContent SRPusebutton = null;
  63. GUIContent Functionsbutton = null;
  64. GUIContent Templatesbutton = null;
  65. GUIContent APIbutton = null;
  66. GUIContent SGtoASEbutton = null;
  67. GUIContent DiscordButton = null;
  68. GUIContent ForumButton = null;
  69. GUIContent ASEIcon = null;
  70. RenderTexture rt;
  71. [NonSerialized]
  72. GUIStyle m_buttonStyle = null;
  73. [NonSerialized]
  74. GUIStyle m_buttonLeftStyle = null;
  75. [NonSerialized]
  76. GUIStyle m_buttonRightStyle = null;
  77. [NonSerialized]
  78. GUIStyle m_minibuttonStyle = null;
  79. [NonSerialized]
  80. GUIStyle m_labelStyle = null;
  81. [NonSerialized]
  82. GUIStyle m_linkStyle = null;
  83. private ChangeLogInfo m_changeLog;
  84. private bool m_infoDownloaded = false;
  85. private string m_newVersion = string.Empty;
  86. private static Dictionary<int, ASESRPPackageDesc> m_srpSamplePackages = new Dictionary<int, ASESRPPackageDesc>()
  87. {
  88. { ( int )ASESRPBaseline.ASE_SRP_10, new ASESRPPackageDesc( ASESRPBaseline.ASE_SRP_10, "2edbf4a9b9544774bbef617e92429664", "9da5530d5ebfab24c8ecad68795e720f" ) },
  89. { ( int )ASESRPBaseline.ASE_SRP_11, new ASESRPPackageDesc( ASESRPBaseline.ASE_SRP_11, "2edbf4a9b9544774bbef617e92429664", "9da5530d5ebfab24c8ecad68795e720f" ) },
  90. { ( int )ASESRPBaseline.ASE_SRP_12, new ASESRPPackageDesc( ASESRPBaseline.ASE_SRP_12, "13ab599a7bda4e54fba3e92a13c9580a", "aa102d640b98b5d4781710a3a3dd6983" ) },
  91. { ( int )ASESRPBaseline.ASE_SRP_13, new ASESRPPackageDesc( ASESRPBaseline.ASE_SRP_13, "13ab599a7bda4e54fba3e92a13c9580a", "aa102d640b98b5d4781710a3a3dd6983" ) },
  92. { ( int )ASESRPBaseline.ASE_SRP_14, new ASESRPPackageDesc( ASESRPBaseline.ASE_SRP_14, "f6f268949ccf3f34fa4d18e92501ed82", "7a0bb33169d95ec499136d59cb25918b" ) },
  93. { ( int )ASESRPBaseline.ASE_SRP_15, new ASESRPPackageDesc( ASESRPBaseline.ASE_SRP_15, "69bc3229216b1504ea3e28b5820bbb0d", "641c955d37d2fac4f87e00ac5c9d9bd8" ) },
  94. { ( int )ASESRPBaseline.ASE_SRP_16, new ASESRPPackageDesc( ASESRPBaseline.ASE_SRP_16, "4f665a06c5a2aa5499fa1c79ac058999", "2690f45490c175045bbdc63395bf6278" ) },
  95. { ( int )ASESRPBaseline.ASE_SRP_17, new ASESRPPackageDesc( ASESRPBaseline.ASE_SRP_17, "47fc5ccecd261894994c1e9e827cf553", "f42c2bc4dab4723429b0d30b635c3035" ) },
  96. };
  97. private void OnEnable()
  98. {
  99. rt = new RenderTexture( 16, 16, 0 );
  100. rt.Create();
  101. m_startup = (Preferences.ShowOption)EditorPrefs.GetInt( Preferences.User.Keys.StartUp, 0 );
  102. if( textIcon == null )
  103. {
  104. Texture icon = EditorGUIUtility.IconContent( "TextAsset Icon" ).image;
  105. var cache = RenderTexture.active;
  106. RenderTexture.active = rt;
  107. Graphics.Blit( icon, rt );
  108. RenderTexture.active = cache;
  109. textIcon = rt;
  110. Manualbutton = new GUIContent( " Manual", textIcon );
  111. Basicbutton = new GUIContent( " Basic use tutorials", textIcon );
  112. Beginnerbutton = new GUIContent( " Beginner Series", textIcon );
  113. Nodesbutton = new GUIContent( " Node List", textIcon );
  114. SRPusebutton = new GUIContent( " SRP HDRP/URP use", textIcon );
  115. Functionsbutton = new GUIContent( " Shader Functions", textIcon );
  116. Templatesbutton = new GUIContent( " Shader Templates", textIcon );
  117. APIbutton = new GUIContent( " Node API", textIcon );
  118. SGtoASEbutton = new GUIContent( " Shader Graph to ASE", textIcon );
  119. }
  120. if( packageIcon == null )
  121. {
  122. packageIcon = EditorGUIUtility.IconContent( "BuildSettings.Editor.Small" ).image;
  123. HDRPbutton = new GUIContent( " HDRP Samples", packageIcon );
  124. URPbutton = new GUIContent( " URP Samples", packageIcon );
  125. BuiltInbutton = new GUIContent( " Built-In Samples", packageIcon );
  126. }
  127. if( webIcon == null )
  128. {
  129. webIcon = EditorGUIUtility.IconContent( "BuildSettings.Web.Small" ).image;
  130. DiscordButton = new GUIContent( " Discord", webIcon );
  131. ForumButton = new GUIContent( " Unity Forum", webIcon );
  132. }
  133. if( m_changeLog == null )
  134. {
  135. var changelog = AssetDatabase.LoadAssetAtPath<TextAsset>( AssetDatabase.GUIDToAssetPath( ChangeLogGUID ) );
  136. string lastUpdate = string.Empty;
  137. if(changelog != null )
  138. {
  139. int oldestReleaseIndex = changelog.text.LastIndexOf( string.Format( "v{0}.{1}.{2}", VersionInfo.Major, VersionInfo.Minor, VersionInfo.Release ) );
  140. lastUpdate = changelog.text.Substring( 0, changelog.text.IndexOf( "\nv", oldestReleaseIndex + 25 ) );// + "\n...";
  141. lastUpdate = lastUpdate.Replace( "* ", "\u2022 " );
  142. }
  143. m_changeLog = new ChangeLogInfo( VersionInfo.FullNumber, lastUpdate );
  144. }
  145. if( ASEIcon == null )
  146. {
  147. ASEIcon = new GUIContent( AssetDatabase.LoadAssetAtPath<Texture2D>( AssetDatabase.GUIDToAssetPath( IconGUID ) ) );
  148. }
  149. }
  150. private void OnDisable()
  151. {
  152. if( rt != null )
  153. {
  154. rt.Release();
  155. DestroyImmediate( rt );
  156. }
  157. }
  158. public void OnGUI()
  159. {
  160. if( !m_infoDownloaded )
  161. {
  162. m_infoDownloaded = true;
  163. StartBackgroundTask( StartRequest( ChangelogURL, () =>
  164. {
  165. var temp = ChangeLogInfo.CreateFromJSON( www.downloadHandler.text );
  166. if( temp != null && temp.Version >= m_changeLog.Version )
  167. {
  168. m_changeLog = temp;
  169. }
  170. int version = m_changeLog.Version;
  171. int major = version / 10000;
  172. int minor = version / 1000 - major * 10;
  173. int release = version / 100 - ( version / 1000 ) * 10;
  174. int revision = version - ( version / 100 ) * 100;
  175. m_newVersion = major + "." + minor + "." + release + ( revision > 0 ? "." + revision : "" );
  176. Repaint();
  177. } ) );
  178. }
  179. if( m_buttonStyle == null )
  180. {
  181. m_buttonStyle = new GUIStyle( GUI.skin.button );
  182. m_buttonStyle.alignment = TextAnchor.MiddleLeft;
  183. }
  184. if( m_buttonLeftStyle == null )
  185. {
  186. m_buttonLeftStyle = new GUIStyle( "ButtonLeft" );
  187. m_buttonLeftStyle.alignment = TextAnchor.MiddleLeft;
  188. m_buttonLeftStyle.margin = m_buttonStyle.margin;
  189. m_buttonLeftStyle.margin.right = 0;
  190. }
  191. if( m_buttonRightStyle == null )
  192. {
  193. m_buttonRightStyle = new GUIStyle( "ButtonRight" );
  194. m_buttonRightStyle.alignment = TextAnchor.MiddleLeft;
  195. m_buttonRightStyle.margin = m_buttonStyle.margin;
  196. m_buttonRightStyle.margin.left = 0;
  197. }
  198. if( m_minibuttonStyle == null )
  199. {
  200. m_minibuttonStyle = new GUIStyle( "MiniButton" );
  201. m_minibuttonStyle.alignment = TextAnchor.MiddleLeft;
  202. m_minibuttonStyle.margin = m_buttonStyle.margin;
  203. m_minibuttonStyle.margin.left = 20;
  204. m_minibuttonStyle.normal.textColor = m_buttonStyle.normal.textColor;
  205. m_minibuttonStyle.hover.textColor = m_buttonStyle.hover.textColor;
  206. }
  207. if( m_labelStyle == null )
  208. {
  209. m_labelStyle = new GUIStyle( "BoldLabel" );
  210. m_labelStyle.margin = new RectOffset( 4, 4, 4, 4 );
  211. m_labelStyle.padding = new RectOffset( 2, 2, 2, 2 );
  212. m_labelStyle.fontSize = 13;
  213. }
  214. if( m_linkStyle == null )
  215. {
  216. var inv = AssetDatabase.LoadAssetAtPath<Texture2D>( AssetDatabase.GUIDToAssetPath( "1004d06b4b28f5943abdf2313a22790a" ) ); // find a better solution for transparent buttons
  217. m_linkStyle = new GUIStyle();
  218. m_linkStyle.normal.textColor = new Color( 0.2980392f, 0.4901961f, 1f );
  219. m_linkStyle.hover.textColor = Color.white;
  220. m_linkStyle.active.textColor = Color.grey;
  221. m_linkStyle.margin.top = 3;
  222. m_linkStyle.margin.bottom = 2;
  223. m_linkStyle.hover.background = inv;
  224. m_linkStyle.active.background = inv;
  225. }
  226. EditorGUILayout.BeginHorizontal( GUIStyle.none, GUILayout.ExpandWidth( true ) );
  227. {
  228. // left column
  229. EditorGUILayout.BeginVertical( GUILayout.Width( 175 ) );
  230. {
  231. GUILayout.Label( SamplesTitle, m_labelStyle );
  232. EditorGUILayout.BeginHorizontal();
  233. if( GUILayout.Button( HDRPbutton, m_buttonLeftStyle ) )
  234. ImportSample( HDRPbutton.text, TemplateSRPType.HDRP );
  235. EditorGUILayout.EndHorizontal();
  236. EditorGUILayout.BeginHorizontal();
  237. if( GUILayout.Button( URPbutton, m_buttonLeftStyle ) )
  238. ImportSample( URPbutton.text, TemplateSRPType.URP );
  239. EditorGUILayout.EndHorizontal();
  240. if( GUILayout.Button( BuiltInbutton, m_buttonStyle ) )
  241. ImportSample( BuiltInbutton.text, TemplateSRPType.BiRP );
  242. GUILayout.Space( 10 );
  243. GUILayout.Label( ResourcesTitle, m_labelStyle );
  244. if( GUILayout.Button( Manualbutton, m_buttonStyle ) )
  245. Application.OpenURL( ManualURL );
  246. if( GUILayout.Button( Basicbutton, m_buttonStyle ) )
  247. Application.OpenURL( BasicURL );
  248. if( GUILayout.Button( Beginnerbutton, m_buttonStyle ) )
  249. Application.OpenURL( BeginnerURL );
  250. if( GUILayout.Button( Nodesbutton, m_buttonStyle ) )
  251. Application.OpenURL( NodesURL );
  252. if( GUILayout.Button( SRPusebutton, m_buttonStyle ) )
  253. Application.OpenURL( SRPURL );
  254. if( GUILayout.Button( Functionsbutton, m_buttonStyle ) )
  255. Application.OpenURL( FunctionsURL );
  256. if( GUILayout.Button( Templatesbutton, m_buttonStyle ) )
  257. Application.OpenURL( TemplatesURL );
  258. if( GUILayout.Button( APIbutton, m_buttonStyle ) )
  259. Application.OpenURL( APIURL );
  260. if ( GUILayout.Button( SGtoASEbutton, m_buttonStyle ) )
  261. Application.OpenURL( SGtoASEURL );
  262. }
  263. EditorGUILayout.EndVertical();
  264. // right column
  265. EditorGUILayout.BeginVertical( GUILayout.Width( 650 - 175 - 9 ), GUILayout.ExpandHeight( true ) );
  266. {
  267. GUILayout.Label( CommunityTitle, m_labelStyle );
  268. EditorGUILayout.BeginHorizontal( GUILayout.ExpandWidth( true ) );
  269. {
  270. if( GUILayout.Button( DiscordButton, GUILayout.ExpandWidth( true ) ) )
  271. {
  272. Application.OpenURL( DiscordURL );
  273. }
  274. if( GUILayout.Button( ForumButton, GUILayout.ExpandWidth( true ) ) )
  275. {
  276. Application.OpenURL( ForumURL );
  277. }
  278. }
  279. EditorGUILayout.EndHorizontal();
  280. GUILayout.Label( UpdateTitle, m_labelStyle );
  281. m_scrollPosition = GUILayout.BeginScrollView( m_scrollPosition, "ProgressBarBack", GUILayout.ExpandHeight( true ), GUILayout.ExpandWidth( true ) );
  282. GUILayout.Label( m_changeLog.LastUpdate, "WordWrappedMiniLabel", GUILayout.ExpandHeight( true ) );
  283. GUILayout.EndScrollView();
  284. EditorGUILayout.BeginHorizontal( GUILayout.ExpandWidth( true ) );
  285. {
  286. EditorGUILayout.BeginVertical();
  287. GUILayout.Label( ASETitle, m_labelStyle );
  288. GUILayout.Label( "Installed Version: " + VersionInfo.StaticToString() );
  289. if( m_changeLog.Version > VersionInfo.FullNumber )
  290. {
  291. var cache = GUI.color;
  292. GUI.color = Color.red;
  293. GUILayout.Label( "New version available: " + m_newVersion, "BoldLabel" );
  294. GUI.color = cache;
  295. }
  296. else
  297. {
  298. var cache = GUI.color;
  299. GUI.color = Color.green;
  300. GUILayout.Label( "You are using the latest version", "BoldLabel" );
  301. GUI.color = cache;
  302. }
  303. EditorGUILayout.BeginHorizontal();
  304. GUILayout.Label( "Download links:" );
  305. if( GUILayout.Button( "Amplify", m_linkStyle ) )
  306. Application.OpenURL( SiteURL );
  307. GUILayout.Label( "-" );
  308. if( GUILayout.Button( "Asset Store", m_linkStyle ) )
  309. Application.OpenURL( StoreURL );
  310. EditorGUILayout.EndHorizontal();
  311. GUILayout.Space( 7 );
  312. EditorGUILayout.EndVertical();
  313. GUILayout.FlexibleSpace();
  314. EditorGUILayout.BeginVertical();
  315. GUILayout.Space( 7 );
  316. GUILayout.Label( ASEIcon );
  317. EditorGUILayout.EndVertical();
  318. }
  319. EditorGUILayout.EndHorizontal();
  320. }
  321. EditorGUILayout.EndVertical();
  322. }
  323. EditorGUILayout.EndHorizontal();
  324. EditorGUILayout.BeginHorizontal( "ProjectBrowserBottomBarBg", GUILayout.ExpandWidth( true ), GUILayout.Height(22) );
  325. {
  326. GUILayout.FlexibleSpace();
  327. EditorGUI.BeginChangeCheck();
  328. var cache = EditorGUIUtility.labelWidth;
  329. EditorGUIUtility.labelWidth = 100;
  330. m_startup = (Preferences.ShowOption)EditorGUILayout.EnumPopup( "Show At Startup", m_startup, GUILayout.Width( 220 ) );
  331. EditorGUIUtility.labelWidth = cache;
  332. if( EditorGUI.EndChangeCheck() )
  333. {
  334. EditorPrefs.SetInt( Preferences.User.Keys.StartUp, (int)m_startup );
  335. }
  336. }
  337. EditorGUILayout.EndHorizontal();
  338. }
  339. void ImportSample( string pipeline, TemplateSRPType srpType )
  340. {
  341. if( EditorUtility.DisplayDialog( "Import Sample", "This will import the samples for" + pipeline.Replace( " Samples", "" ) + ", please make sure the pipeline is properly installed and/or selected before importing the samples.\n\nContinue?", "Yes", "No" ) )
  342. {
  343. AssetDatabase.ImportPackage( AssetDatabase.GUIDToAssetPath( ResourcesGUID ), false );
  344. switch ( srpType )
  345. {
  346. case TemplateSRPType.BiRP:
  347. {
  348. AssetDatabase.ImportPackage( AssetDatabase.GUIDToAssetPath( BuiltInGUID ), false );
  349. break;
  350. }
  351. case TemplateSRPType.URP:
  352. {
  353. if ( m_srpSamplePackages.TryGetValue( ( int )ASEPackageManagerHelper.CurrentURPBaseline, out ASESRPPackageDesc desc ) )
  354. {
  355. string path = AssetDatabase.GUIDToAssetPath( desc.guidURP );
  356. if ( !string.IsNullOrEmpty( path ) )
  357. {
  358. AssetDatabase.ImportPackage( AssetDatabase.GUIDToAssetPath( UniversalGUID ), false );
  359. AssetDatabase.ImportPackage( path, false );
  360. }
  361. }
  362. break;
  363. }
  364. case TemplateSRPType.HDRP:
  365. {
  366. if ( m_srpSamplePackages.TryGetValue( ( int )ASEPackageManagerHelper.CurrentHDRPBaseline, out ASESRPPackageDesc desc ) )
  367. {
  368. string path = AssetDatabase.GUIDToAssetPath( desc.guidHDRP );
  369. if ( !string.IsNullOrEmpty( path ) )
  370. {
  371. AssetDatabase.ImportPackage( AssetDatabase.GUIDToAssetPath( HighDefinitionGUID ), false );
  372. AssetDatabase.ImportPackage( path, false );
  373. }
  374. }
  375. break;
  376. }
  377. default:
  378. {
  379. // no action
  380. break;
  381. }
  382. }
  383. }
  384. }
  385. UnityWebRequest www;
  386. IEnumerator StartRequest( string url, Action success = null )
  387. {
  388. using( www = UnityWebRequest.Get( url ) )
  389. {
  390. yield return www.SendWebRequest();
  391. while( www.isDone == false )
  392. yield return null;
  393. if( success != null )
  394. success();
  395. }
  396. }
  397. public static void StartBackgroundTask( IEnumerator update, Action end = null )
  398. {
  399. EditorApplication.CallbackFunction closureCallback = null;
  400. closureCallback = () =>
  401. {
  402. try
  403. {
  404. if( update.MoveNext() == false )
  405. {
  406. if( end != null )
  407. end();
  408. EditorApplication.update -= closureCallback;
  409. }
  410. }
  411. catch( Exception ex )
  412. {
  413. if( end != null )
  414. end();
  415. Debug.LogException( ex );
  416. EditorApplication.update -= closureCallback;
  417. }
  418. };
  419. EditorApplication.update += closureCallback;
  420. }
  421. }
  422. [Serializable]
  423. internal class ChangeLogInfo
  424. {
  425. public int Version;
  426. public string LastUpdate;
  427. public static ChangeLogInfo CreateFromJSON( string jsonString )
  428. {
  429. return JsonUtility.FromJson<ChangeLogInfo>( jsonString );
  430. }
  431. public ChangeLogInfo( int version, string lastUpdate )
  432. {
  433. Version = version;
  434. LastUpdate = lastUpdate;
  435. }
  436. }
  437. }