public static void FinishImporter() { m_importingPackage = ASEImportState.None; AssetDatabase.importPackageCancelled -= CancelledPackageImport; AssetDatabase.importPackageCompleted -= CompletedPackageImport; AssetDatabase.importPackageFailed -= FailedPackageImport; }
public static void StartImporting(string packagePath) { if (!Preferences.GlobalAutoSRP) { m_importingPackage = ASEImportState.None; return; } if (Application.isPlaying) { if (!m_lateImport) { m_lateImport = true; m_latePackageToImport = packagePath; Debug.LogWarning("Amplify Shader Editor requires the \"" + packagePath + "\" package to be installed in order to continue. Please exit Play mode to proceed."); } return; } AssetDatabase.importPackageCancelled += CancelledPackageImport; AssetDatabase.importPackageCompleted += CompletedPackageImport; AssetDatabase.importPackageFailed += FailedPackageImport; AssetDatabase.ImportPackage(packagePath, false); //AssetDatabaseEX.ImportPackageImmediately( packagePath ); }
public static void StartImporting(string packagePath) { if (!Preferences.GlobalAutoSRP) { m_importingPackage = ASEImportState.None; return; } AssetDatabase.importPackageCancelled += CancelledPackageImport; AssetDatabase.importPackageCompleted += CompletedPackageImport; AssetDatabase.importPackageFailed += FailedPackageImport; AssetDatabase.ImportPackage(packagePath, false); //AssetDatabaseEX.ImportPackageImmediately( packagePath ); }
public static void Update() { //if( Application.isPlaying ) // return; CheckLatePackageImport(); //if( m_lwPackageInfo != null ) //{ // if( m_srpVersionConverter[ m_lwPackageInfo.version ] != m_currentLWVersion ) // { // m_currentLWVersion = m_srpVersionConverter[ m_lwPackageInfo.version ]; // EditorPrefs.SetInt( LWEditorPrefsId, (int)m_currentLWVersion ); // m_importingPackage = ASEImportState.Lightweight; // string packagePath = AssetDatabase.GUIDToAssetPath( m_srpToASEPackageLW[ m_currentLWVersion ] ); // StartImporting( packagePath ); // } //} //if( m_hdPackageInfo != null ) //{ // if( m_srpVersionConverter[ m_hdPackageInfo.version ] != m_currentHDVersion ) // { // m_currentHDVersion = m_srpVersionConverter[ m_hdPackageInfo.version ]; // EditorPrefs.SetInt( HDEditorPrefsId, (int)m_currentHDVersion ); // m_importingPackage = ASEImportState.HD; // string packagePath = AssetDatabase.GUIDToAssetPath( m_srpToASEPackageHD[ m_currentHDVersion ] ); // StartImporting( packagePath ); // } //} if (m_requireUpdateList && m_importingPackage == ASEImportState.None) { if (m_packageListRequest != null && m_packageListRequest.IsCompleted) { m_requireUpdateList = false; foreach (UnityEditor.PackageManager.PackageInfo pi in m_packageListRequest.Result) { if (pi.name.Equals(LWPackageId)) { m_currentLWVersion = ASESRPVersions.ASE_SRP_RECENT; m_lwPackageInfo = pi; ASESRPVersions oldVersion = (ASESRPVersions)EditorPrefs.GetInt(LWEditorPrefsId); if (m_srpVersionConverter.ContainsKey(pi.version)) { m_currentLWVersion = m_srpVersionConverter[pi.version]; } else { m_currentLWVersion = ASESRPVersions.ASE_SRP_RECENT; } EditorPrefs.SetInt(LWEditorPrefsId, (int)m_currentLWVersion); bool foundNewVersion = oldVersion != m_currentLWVersion; if (!File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.LightweigthPBRGUID)) || !File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.LightweigthUnlitGUID)) || foundNewVersion ) { if (foundNewVersion) { Debug.Log(LightweightNewVersionDetected); } m_importingPackage = ASEImportState.Lightweight; string guid = m_srpToASEPackageLW.ContainsKey(m_currentLWVersion) ? m_srpToASEPackageLW[m_currentLWVersion] : m_srpToASEPackageLW[ASESRPVersions.ASE_SRP_RECENT]; string packagePath = AssetDatabase.GUIDToAssetPath(guid); StartImporting(packagePath); } } if (pi.name.Equals(UniversalPackageId)) { m_currentLWVersion = ASESRPVersions.ASE_SRP_RECENT; m_lwPackageInfo = pi; ASESRPVersions oldVersion = (ASESRPVersions)EditorPrefs.GetInt(LWEditorPrefsId); if (m_srpVersionConverter.ContainsKey(pi.version)) { m_currentLWVersion = m_srpVersionConverter[pi.version]; } else { m_currentLWVersion = ASESRPVersions.ASE_SRP_RECENT; } EditorPrefs.SetInt(LWEditorPrefsId, (int)m_currentLWVersion); bool foundNewVersion = oldVersion != m_currentLWVersion; int urpVersion = EditorPrefs.GetInt(URPTemplateVersion, m_urpTemplateVersion); if (urpVersion < m_urpTemplateVersion) { foundNewVersion = true; } EditorPrefs.SetInt(URPTemplateVersion, m_urpTemplateVersion); if (!File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.UniversalPBRGUID)) || !File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.UniversalUnlitGUID)) || foundNewVersion ) { if (foundNewVersion) { Debug.Log(LightweightNewVersionDetected); } m_importingPackage = ASEImportState.Lightweight; string guid = m_srpToASEPackageLW.ContainsKey(m_currentLWVersion) ? m_srpToASEPackageLW[m_currentLWVersion] : m_srpToASEPackageLW[ASESRPVersions.ASE_SRP_RECENT]; string packagePath = AssetDatabase.GUIDToAssetPath(guid); StartImporting(packagePath); } } if (pi.name.Equals(HDPackageId)) { m_currentHDVersion = ASESRPVersions.ASE_SRP_RECENT; m_hdPackageInfo = pi; ASESRPVersions oldVersion = (ASESRPVersions)EditorPrefs.GetInt(HDEditorPrefsId); if (m_srpVersionConverter.ContainsKey(pi.version)) { m_currentHDVersion = m_srpVersionConverter[pi.version]; } else { m_currentHDVersion = ASESRPVersions.ASE_SRP_RECENT; } EditorPrefs.SetInt(HDEditorPrefsId, (int)m_currentHDVersion); bool foundNewVersion = oldVersion != m_currentHDVersion; int hdrpVersion = EditorPrefs.GetInt(HDRPTemplateVersion, m_hdrpTemplateVersion); if (hdrpVersion < m_hdrpTemplateVersion) { foundNewVersion = true; } EditorPrefs.SetInt(HDRPTemplateVersion, m_hdrpTemplateVersion); #if UNITY_2019_3_OR_NEWER if (!File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.HDNewLitGUID)) || !File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.HDNewPBRGUID)) || !File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.HDNewUnlitGUID)) || #else if (!File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.HDLitGUID)) || !File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.HDPBRGUID)) || !File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.HDUnlitGUID)) || #endif foundNewVersion ) { if (foundNewVersion) { Debug.Log(HDNewVersionDetected); } m_importingPackage = m_importingPackage == ASEImportState.Lightweight ? ASEImportState.Both : ASEImportState.HD; string guid = m_srpToASEPackageHD.ContainsKey(m_currentHDVersion) ? m_srpToASEPackageHD[m_currentHDVersion] : m_srpToASEPackageHD[ASESRPVersions.ASE_SRP_RECENT]; string packagePath = AssetDatabase.GUIDToAssetPath(guid); StartImporting(packagePath); } } } } } }
public static void Update() { //if( m_lwPackageInfo != null ) //{ // if( m_srpVersionConverter[ m_lwPackageInfo.version ] != m_currentLWVersion ) // { // m_currentLWVersion = m_srpVersionConverter[ m_lwPackageInfo.version ]; // EditorPrefs.SetInt( LWEditorPrefsId, (int)m_currentLWVersion ); // m_importingPackage = ASEImportState.Lightweight; // string packagePath = AssetDatabase.GUIDToAssetPath( m_srpToASEPackageLW[ m_currentLWVersion ] ); // StartImporting( packagePath ); // } //} //if( m_hdPackageInfo != null ) //{ // if( m_srpVersionConverter[ m_hdPackageInfo.version ] != m_currentHDVersion ) // { // m_currentHDVersion = m_srpVersionConverter[ m_hdPackageInfo.version ]; // EditorPrefs.SetInt( HDEditorPrefsId, (int)m_currentHDVersion ); // m_importingPackage = ASEImportState.HD; // string packagePath = AssetDatabase.GUIDToAssetPath( m_srpToASEPackageHD[ m_currentHDVersion ] ); // StartImporting( packagePath ); // } //} if (m_requireUpdateList && m_importingPackage == ASEImportState.None) { if (m_packageListRequest != null && m_packageListRequest.IsCompleted) { m_requireUpdateList = false; foreach (UnityEditor.PackageManager.PackageInfo pi in m_packageListRequest.Result) { if (pi.name.Equals(LWPackageId)) { m_lwPackageInfo = pi; if (m_srpVersionConverter.ContainsKey(pi.version)) { ASESRPVersions oldVersion = (ASESRPVersions)EditorPrefs.GetInt(LWEditorPrefsId); m_currentLWVersion = m_srpVersionConverter[pi.version]; EditorPrefs.SetInt(LWEditorPrefsId, (int)m_currentLWVersion); bool foundNewVersion = oldVersion != m_currentLWVersion; if (!File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.LightweigthPBRGUID)) || !File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.LightweigthUnlitGUID)) || foundNewVersion ) { if (foundNewVersion) { Debug.Log(LightweightNewVersionDetected); } m_importingPackage = ASEImportState.Lightweight; string packagePath = AssetDatabase.GUIDToAssetPath(m_srpToASEPackageLW[m_currentLWVersion]); StartImporting(packagePath); } } } if (pi.name.Equals(HDPackageId)) { m_hdPackageInfo = pi; if (m_srpVersionConverter.ContainsKey(pi.version)) { ASESRPVersions oldVersion = (ASESRPVersions)EditorPrefs.GetInt(HDEditorPrefsId); EditorPrefs.SetInt(HDEditorPrefsId, (int)m_currentHDVersion); m_currentHDVersion = m_srpVersionConverter[pi.version]; bool foundNewVersion = oldVersion != m_currentHDVersion; if (!File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.HDLitGUID)) || !File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.HDPBRGUID)) || !File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.HDUnlitGUID)) || foundNewVersion ) { if (foundNewVersion) { Debug.Log(HDNewVersionDetected); } m_importingPackage = m_importingPackage == ASEImportState.Lightweight ? ASEImportState.Both : ASEImportState.HD; string packagePath = AssetDatabase.GUIDToAssetPath(m_srpToASEPackageHD[m_currentHDVersion]); StartImporting(packagePath); } } } } } } }