Esempio n. 1
0
        // Delete the version of the sky studio shader that uses global keywords if the
        // platform supports using local keywords.
        static void CheckAndDeleteGlobalShaderKeywordsFile()
        {
            if (!SkyEditorUtility.SupportsLocalKeywords())
            {
                return;
            }

            Shader globalShader = Shader.Find(SkyProfile.DefaultLegacyShaderName);

            // Check if it's already been deleted.
            if (globalShader == null)
            {
                return;
            }

            string assetPath = AssetDatabase.GetAssetPath(globalShader);

            if (assetPath == null)
            {
                return;
            }

            if (!AssetDatabase.DeleteAsset(assetPath))
            {
                Debug.LogWarning("Failed to delete legacy Sky Studio shader.");
            }

            AssetDatabase.SaveAssets();
        }
Esempio n. 2
0
        static void RunFullMigration()
        {
            EditorPrefs.SetInt(migrationVersionKey, migrationVersion);
            EditorPrefs.SetString(migrationUnityVersionKey, Application.version);

            // No migration necessary since we're on an older version of Unity.
            if (!SkyEditorUtility.SupportsLocalKeywords())
            {
                return;
            }

            // Upgrade all the skybox materials in the project.
            string[] guids = AssetDatabase.FindAssets("t:material");

            foreach (string guid in guids)
            {
                string assetPath = AssetDatabase.GUIDToAssetPath(guid);
                if (assetPath == null)
                {
                    continue;
                }

                // Upgrade the material if it's a legacy sky studio material.
                CheckAndRepairSkyStudioMaterial(assetPath);
            }

            // Delete the legacy shader since it's no longer being used by materials.
            CheckAndDeleteGlobalShaderKeywordsFile();
        }