Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

2021.2.0 Beta 4 not showing menu to upgrade material (URP)

Discussion in '2021.2 Beta' started by antoniomonteiro, Jul 18, 2021.

  1. antoniomonteiro

    antoniomonteiro

    Joined:
    Nov 25, 2017
    Posts:
    4
    I Created a new project (3, actually) with URP template and is not showing the menu in edit - Render Pipeline - Universal Render Pipeline to upgrade materials do URP

    I dont know if its a bug or changed places, but if i create with 2021.1 works fine
     
    Last edited: Jul 18, 2021
  2. Sab_Rango

    Sab_Rango

    Joined:
    Aug 30, 2019
    Posts:
    121
    The same with beta 2 and 3. It must be a bug if there is no a new tech that is coming with it.
     
  3. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    527
    I found Window/Rendering/Render Pipeline Converter which seems like a more fancy version of the old direct conversion. Not sure if it is the same/successor though.
     
  4. Sab_Rango

    Sab_Rango

    Joined:
    Aug 30, 2019
    Posts:
    121
    Nice!! It works !

    Window/Rendering/Render Pipeline Converter
     
  5. ZenUnity

    ZenUnity

    Joined:
    Apr 21, 2013
    Posts:
    28
    It would be great if you could drag and drop the materials you'd like to upgrade into the window instead of having the Render Pipeline Converter creating it's own list of materials it thinks need to be upgraded. For large projects it is a pain to go and uncheck all of the materials you don't want to upgrade.
     
  6. andreiagmu

    andreiagmu

    Joined:
    Feb 20, 2014
    Posts:
    175
    I agree, being able to select specific materials/assets to be upgraded is a VERY essential feature, which the new converters are currently missing.
     
    Haapavuo and Lars-Steenhoff like this.
  7. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,526
    Yes before I could upgrade a material in a few seconds, now it takes a long time to even generate the list.
     
    Haapavuo and andreiagmu like this.
  8. crayo7

    crayo7

    Joined:
    Feb 10, 2018
    Posts:
    1
    Thanks god.
    You saved my life
     
    ImpossibleRobert likes this.
  9. Lorrak

    Lorrak

    Joined:
    Sep 17, 2019
    Posts:
    50
    thanks!
     
  10. alec100_94

    alec100_94

    Joined:
    Jan 9, 2017
    Posts:
    26
    This was causing me an issue to the point where it was damaging my workflow. Too many things need upgrading to URP if you're using assets and the new converter is way too cumbersome. The old system was much better but still less than perfect because you needed to have all the materials you wanted selected, so I wrote a script to reimplement the old upgrade methods and add an extra one to upgrade all the materials in a selected folder (including sub-folders) too (which makes way more sense for what I need it for). Just drop this into your project (optionally an Editor folder) and choose the options from Edit > Universal Render Pipeline (similar to how it was in earlier versions of URP). Most of this code was copied/adapted from unity's underlying implementation in

    UnityEditor.Rendering.Universal.UniversalRenderPipelineMaterialUpgrader and
    UnityEditor.Rendering.MaterialUpdater


    the former of which is internal so has to be reimplemented to access (at least without reflection).
    Hope someone finds this useful, and I would like to see unity implement a more sane official solution in the future, as non URP materials aren't a problem going away any time soon.

    Code (CSharp):
    1. #if UNITY_EDITOR
    2. using System;
    3. using System.Collections.Generic;
    4. using System.IO;
    5. using System.Linq;
    6. using UnityEditor.Rendering;
    7. using UnityEditor.Rendering.Universal;
    8. using UnityEngine;
    9. using UnityEngine.Rendering;
    10. using UnityEngine.Rendering.Universal;
    11. using static UnityEditor.Rendering.MaterialUpgrader;
    12.  
    13. namespace UnityEditor.UnityFixes
    14. {
    15.     public static class URPMaterialUpgrader
    16.     {
    17.         [MenuItem("Edit/Universal Render Pipeline/Upgrade Project Materials to UniversalRP Materials")]
    18.         private static void UpgradeProjectMaterials()
    19.         {
    20.             List<MaterialUpgrader> upgraders = new List<MaterialUpgrader>();
    21.             GetUpgraders(ref upgraders);
    22.  
    23.             HashSet<string> shaderNamesToIgnore = new HashSet<string>();
    24.             GetShaderNamesToIgnore(ref shaderNamesToIgnore);
    25.  
    26.             MaterialUpgrader.UpgradeProjectFolder(upgraders, shaderNamesToIgnore, "Upgrade to URP Materials", MaterialUpgrader.UpgradeFlags.LogMessageWhenNoUpgraderFound);
    27.         }
    28.  
    29.         [MenuItem("Edit/Universal Render Pipeline/Upgrade Selected Materials to UniversalRP Materials")]
    30.         private static void UpgradeSelectedMaterials()
    31.         {
    32.             List<MaterialUpgrader> upgraders = new List<MaterialUpgrader>();
    33.             GetUpgraders(ref upgraders);
    34.  
    35.             HashSet<string> shaderNamesToIgnore = new HashSet<string>();
    36.             GetShaderNamesToIgnore(ref shaderNamesToIgnore);
    37.          
    38.             MaterialUpgrader.UpgradeSelection(upgraders, shaderNamesToIgnore, "Upgrade to URP Materials", MaterialUpgrader.UpgradeFlags.LogMessageWhenNoUpgraderFound);
    39.         }
    40.  
    41.         [MenuItem("Edit/Universal Render Pipeline/Upgrade Materials From Selected Folder to UniversalRP Materials")]
    42.         private static void UpgradeSelectedMaterialsFromFolder()
    43.         {
    44.             List<MaterialUpgrader> upgraders = new List<MaterialUpgrader>();
    45.             GetUpgraders(ref upgraders);
    46.  
    47.             HashSet<string> shaderNamesToIgnore = new HashSet<string>();
    48.             GetShaderNamesToIgnore(ref shaderNamesToIgnore);
    49.          
    50.             if(TryGetSelectedDirectory(out string directoryPath))
    51.                 UpgradeMaterialFromFolder(upgraders, shaderNamesToIgnore, "Upgrade to URP Materials", directoryPath, MaterialUpgrader.UpgradeFlags.LogMessageWhenNoUpgraderFound);
    52.             else EditorUtility.DisplayDialog(DialogText.title, "Folder is not selected.", DialogText.ok);
    53.         }
    54.  
    55.         #region Custom Material Upgraders
    56.         private class StandardSimpleLightingUpgrader : MaterialUpgrader
    57.         {
    58.             public StandardSimpleLightingUpgrader(string oldShaderName, UpgradeParams upgradeParams)
    59.             {
    60.                 if (oldShaderName == null)
    61.                     throw new ArgumentNullException("oldShaderName");
    62.  
    63.                 RenameShader(oldShaderName, ShaderUtils.GetShaderPath(ShaderPathID.SimpleLit), UpdateMaterialKeywords);
    64.  
    65.                 SetFloat("_Surface", (float)upgradeParams.surfaceType);
    66.                 SetFloat("_Blend", (float)upgradeParams.blendMode);
    67.                 SetFloat("_AlphaClip", upgradeParams.alphaClip ? 1 : 0);
    68.                 SetFloat("_SpecularHighlights", (float)upgradeParams.specularSource);
    69.                 SetFloat("_SmoothnessSource", (float)upgradeParams.smoothnessSource);
    70.  
    71.                 RenameTexture("_MainTex", "_BaseMap");
    72.                 RenameColor("_Color", "_BaseColor");
    73.                 RenameFloat("_Shininess", "_Smoothness");
    74.  
    75.                 if (oldShaderName.Contains("Legacy Shaders/Self-Illumin"))
    76.                 {
    77.                     RenameTexture("_Illum", "_EmissionMap");
    78.                     RemoveTexture("_Illum");
    79.                     SetColor("_EmissionColor", Color.white);
    80.                 }
    81.             }
    82.  
    83.             public static void UpdateMaterialKeywords(Material material)
    84.             {
    85.                 if (material == null)
    86.                     throw new ArgumentNullException("material");
    87.  
    88.                 material.shaderKeywords = null;
    89.                 BaseShaderGUI.SetupMaterialBlendMode(material);
    90.                 UpdateMaterialSpecularSource(material);
    91.                 CoreUtils.SetKeyword(material, "_NORMALMAP", material.GetTexture("_BumpMap"));
    92.  
    93.                 // A material's GI flag internally keeps track of whether emission is enabled at all, it's enabled but has no effect
    94.                 // or is enabled and may be modified at runtime. This state depends on the values of the current flag and emissive color.
    95.                 // The fixup routine makes sure that the material is in the correct state if/when changes are made to the mode or color.
    96.                 MaterialEditor.FixupEmissiveFlag(material);
    97.                 bool shouldEmissionBeEnabled = (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.EmissiveIsBlack) == 0;
    98.                 CoreUtils.SetKeyword(material, "_EMISSION", shouldEmissionBeEnabled);
    99.             }
    100.  
    101.             private static void UpdateMaterialSpecularSource(Material material)
    102.             {
    103.                 SpecularSource specSource = (SpecularSource)material.GetFloat("_SpecSource");
    104.                 if (specSource == SpecularSource.NoSpecular)
    105.                 {
    106.                     CoreUtils.SetKeyword(material, "_SPECGLOSSMAP", false);
    107.                     CoreUtils.SetKeyword(material, "_SPECULAR_COLOR", false);
    108.                     CoreUtils.SetKeyword(material, "_GLOSSINESS_FROM_BASE_ALPHA", false);
    109.                 }
    110.                 else
    111.                 {
    112.                     SmoothnessSource glossSource = (SmoothnessSource)material.GetFloat("_SmoothnessSource");
    113.                     bool hasGlossMap = material.GetTexture("_SpecGlossMap");
    114.                     CoreUtils.SetKeyword(material, "_SPECGLOSSMAP", hasGlossMap);
    115.                     CoreUtils.SetKeyword(material, "_SPECULAR_COLOR", !hasGlossMap);
    116.                     CoreUtils.SetKeyword(material, "_GLOSSINESS_FROM_BASE_ALPHA", glossSource == SmoothnessSource.BaseAlpha);
    117.                 }
    118.             }
    119.         }
    120.  
    121.         private class SpeedTreeUpgrader : MaterialUpgrader
    122.         {
    123.             internal SpeedTreeUpgrader(string oldShaderName) =>
    124.                 RenameShader(oldShaderName, ShaderUtils.GetShaderPath(ShaderPathID.SpeedTree7));
    125.         }
    126.  
    127.         private class SpeedTreeBillboardUpgrader : MaterialUpgrader
    128.         {
    129.             internal SpeedTreeBillboardUpgrader(string oldShaderName) =>
    130.                 RenameShader(oldShaderName, ShaderUtils.GetShaderPath(ShaderPathID.SpeedTree7Billboard));
    131.         }
    132.  
    133.         private class SpeedTree8Upgrader : MaterialUpgrader
    134.         {
    135.             internal SpeedTree8Upgrader(string oldShaderName) =>
    136.                 RenameShader(oldShaderName, ShaderUtils.GetShaderPath(ShaderPathID.SpeedTree8));
    137.         }
    138.         #endregion
    139.      
    140.         #region Implementation
    141.         private static void GetShaderNamesToIgnore(ref HashSet<string> shadersToIgnore)
    142.         {
    143.             shadersToIgnore.Add("Universal Render Pipeline/Baked Lit");
    144.             shadersToIgnore.Add("Universal Render Pipeline/Lit");
    145.             shadersToIgnore.Add("Universal Render Pipeline/Particles/Lit");
    146.             shadersToIgnore.Add("Universal Render Pipeline/Particles/Simple Lit");
    147.             shadersToIgnore.Add("Universal Render Pipeline/Particles/Unlit");
    148.             shadersToIgnore.Add("Universal Render Pipeline/Simple Lit");
    149.             shadersToIgnore.Add("Universal Render Pipeline/Nature/SpeedTree7");
    150.             shadersToIgnore.Add("Universal Render Pipeline/Nature/SpeedTree7 Billboard");
    151.             shadersToIgnore.Add("Universal Render Pipeline/Nature/SpeedTree8");
    152.             shadersToIgnore.Add("Universal Render Pipeline/2D/Sprite-Lit-Default");
    153.             shadersToIgnore.Add("Universal Render Pipeline/Terrain/Lit");
    154.             shadersToIgnore.Add("Universal Render Pipeline/Unlit");
    155.             shadersToIgnore.Add("Sprites/Default");
    156.         }
    157.  
    158.         private static void GetUpgraders(ref List<MaterialUpgrader> upgraders)
    159.         {
    160.             /////////////////////////////////////
    161.             //     Unity Standard Upgraders    //
    162.             /////////////////////////////////////
    163.             upgraders.Add(new StandardUpgrader("Standard"));
    164.             upgraders.Add(new StandardUpgrader("Standard (Specular setup)"));
    165.  
    166.             /////////////////////////////////////
    167.             // Legacy Shaders upgraders         /
    168.             /////////////////////////////////////
    169.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Diffuse", SupportedUpgradeParams.diffuseOpaque));
    170.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Diffuse Detail", SupportedUpgradeParams.diffuseOpaque));
    171.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Diffuse Fast", SupportedUpgradeParams.diffuseOpaque));
    172.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Specular", SupportedUpgradeParams.specularOpaque));
    173.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Bumped Diffuse", SupportedUpgradeParams.diffuseOpaque));
    174.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Bumped Specular", SupportedUpgradeParams.specularOpaque));
    175.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Parallax Diffuse", SupportedUpgradeParams.diffuseOpaque));
    176.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Parallax Specular", SupportedUpgradeParams.specularOpaque));
    177.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/VertexLit", SupportedUpgradeParams.specularOpaque));
    178.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Transparent/Cutout/VertexLit", SupportedUpgradeParams.specularAlphaCutout));
    179.  
    180.             // Reflective
    181.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Reflective/Bumped Diffuse", SupportedUpgradeParams.diffuseCubemap));
    182.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Reflective/Bumped Specular", SupportedUpgradeParams.specularCubemap));
    183.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Reflective/Bumped Unlit", SupportedUpgradeParams.diffuseCubemap));
    184.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Reflective/Bumped VertexLit", SupportedUpgradeParams.diffuseCubemap));
    185.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Reflective/Diffuse", SupportedUpgradeParams.diffuseCubemap));
    186.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Reflective/Specular", SupportedUpgradeParams.specularCubemap));
    187.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Reflective/VertexLit", SupportedUpgradeParams.diffuseCubemap));
    188.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Reflective/Parallax Diffuse", SupportedUpgradeParams.diffuseCubemap));
    189.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Reflective/Parallax Specular", SupportedUpgradeParams.specularCubemap));
    190.  
    191.             // Self-Illum upgrader
    192.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Self-Illumin/Diffuse", SupportedUpgradeParams.diffuseOpaque));
    193.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Self-Illumin/Bumped Diffuse", SupportedUpgradeParams.diffuseOpaque));
    194.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Self-Illumin/Parallax Diffuse", SupportedUpgradeParams.diffuseOpaque));
    195.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Self-Illumin/Specular", SupportedUpgradeParams.specularOpaque));
    196.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Self-Illumin/Bumped Specular", SupportedUpgradeParams.specularOpaque));
    197.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Self-Illumin/Parallax Specular", SupportedUpgradeParams.specularOpaque));
    198.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Self-Illumin/VertexLit", SupportedUpgradeParams.specularOpaque));
    199.  
    200.             // Alpha Blended
    201.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Transparent/Diffuse", SupportedUpgradeParams.diffuseAlpha));
    202.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Transparent/Specular", SupportedUpgradeParams.specularAlpha));
    203.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Transparent/Bumped Diffuse", SupportedUpgradeParams.diffuseAlpha));
    204.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Transparent/Bumped Specular", SupportedUpgradeParams.specularAlpha));
    205.  
    206.             // Cutout
    207.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Transparent/Cutout/Diffuse", SupportedUpgradeParams.diffuseAlphaCutout));
    208.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Transparent/Cutout/Specular", SupportedUpgradeParams.specularAlphaCutout));
    209.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Transparent/Cutout/Bumped Diffuse", SupportedUpgradeParams.diffuseAlphaCutout));
    210.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Transparent/Cutout/Bumped Specular", SupportedUpgradeParams.specularAlphaCutout));
    211.  
    212.             // Lightmapped
    213.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Lightmapped/Diffuse", SupportedUpgradeParams.diffuseOpaque));
    214.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Lightmapped/Specular", SupportedUpgradeParams.specularOpaque));
    215.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Lightmapped/VertexLit", SupportedUpgradeParams.specularOpaque));
    216.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Lightmapped/Bumped Diffuse", SupportedUpgradeParams.diffuseOpaque));
    217.             upgraders.Add(new StandardSimpleLightingUpgrader("Legacy Shaders/Lightmapped/Bumped Specular", SupportedUpgradeParams.specularOpaque));
    218.  
    219.             /////////////////////////////////////
    220.             // Sprites Upgraders
    221.             /////////////////////////////////////
    222.             upgraders.Add(new StandardSimpleLightingUpgrader("Sprites/Diffuse", SupportedUpgradeParams.diffuseAlpha));
    223.  
    224.             /////////////////////////////////////
    225.             // UI Upgraders
    226.             /////////////////////////////////////
    227.             upgraders.Add(new StandardSimpleLightingUpgrader("UI/Lit/Bumped", SupportedUpgradeParams.diffuseAlphaCutout));
    228.             upgraders.Add(new StandardSimpleLightingUpgrader("UI/Lit/Detail", SupportedUpgradeParams.diffuseAlphaCutout));
    229.             upgraders.Add(new StandardSimpleLightingUpgrader("UI/Lit/Refraction", SupportedUpgradeParams.diffuseAlphaCutout));
    230.             upgraders.Add(new StandardSimpleLightingUpgrader("UI/Lit/Refraction Detail", SupportedUpgradeParams.diffuseAlphaCutout));
    231.             upgraders.Add(new StandardSimpleLightingUpgrader("UI/Lit/Transparent", SupportedUpgradeParams.diffuseAlpha));
    232.  
    233.  
    234.             /////////////////////////////////////
    235.             // Mobile Upgraders                 /
    236.             /////////////////////////////////////
    237.             upgraders.Add(new StandardSimpleLightingUpgrader("Mobile/Diffuse", SupportedUpgradeParams.diffuseOpaque));
    238.             upgraders.Add(new StandardSimpleLightingUpgrader("Mobile/Bumped Specular", SupportedUpgradeParams.specularOpaque));
    239.             upgraders.Add(new StandardSimpleLightingUpgrader("Mobile/Bumped Specular (1 Directional Light)", SupportedUpgradeParams.specularOpaque));
    240.             upgraders.Add(new StandardSimpleLightingUpgrader("Mobile/Bumped Diffuse", SupportedUpgradeParams.diffuseOpaque));
    241.             upgraders.Add(new StandardSimpleLightingUpgrader("Mobile/Unlit (Supports Lightmap)", SupportedUpgradeParams.diffuseOpaque));
    242.             upgraders.Add(new StandardSimpleLightingUpgrader("Mobile/VertexLit", SupportedUpgradeParams.specularOpaque));
    243.             upgraders.Add(new StandardSimpleLightingUpgrader("Mobile/VertexLit (Only Directional Lights)", SupportedUpgradeParams.specularOpaque));
    244.             upgraders.Add(new StandardSimpleLightingUpgrader("Mobile/Particles/VertexLit Blended", SupportedUpgradeParams.specularOpaque));
    245.  
    246.             ////////////////////////////////////
    247.             // Terrain Upgraders              //
    248.             ////////////////////////////////////
    249.             upgraders.Add(new TerrainUpgrader("Nature/Terrain/Standard"));
    250.             upgraders.Add(new SpeedTreeUpgrader("Nature/SpeedTree"));
    251.             upgraders.Add(new SpeedTreeBillboardUpgrader("Nature/SpeedTree Billboard"));
    252.             upgraders.Add(new SpeedTree8Upgrader("Nature/SpeedTree8"));
    253.  
    254.             ////////////////////////////////////
    255.             // Particle Upgraders             //
    256.             ////////////////////////////////////
    257.             upgraders.Add(new ParticleUpgrader("Particles/Standard Surface"));
    258.             upgraders.Add(new ParticleUpgrader("Particles/Standard Unlit"));
    259.             upgraders.Add(new ParticleUpgrader("Particles/VertexLit Blended"));
    260.  
    261.             ////////////////////////////////////
    262.             // Autodesk Interactive           //
    263.             ////////////////////////////////////
    264.             upgraders.Add(new AutodeskInteractiveUpgrader("Autodesk Interactive"));
    265.         }
    266.  
    267.         private static void UpgradeMaterialFromFolder(List<MaterialUpgrader> upgraders, HashSet<string> shaderNamesToIgnore, string progressBarName, string directoryPath, UpgradeFlags flags = UpgradeFlags.None)
    268.         {
    269.             string[] materialPaths = AssetDatabase.GetAllAssetPaths()
    270.                 .Where(path => path.Contains(directoryPath))
    271.                 .Where(path => path.EndsWith(".mat", StringComparison.OrdinalIgnoreCase))
    272.                 .Where(path => File.Exists(path))
    273.                 .ToArray();
    274.              
    275.             int totalMaterialCount = materialPaths.Length;
    276.  
    277.             if(totalMaterialCount == 0)
    278.             {
    279.                 EditorUtility.DisplayDialog(DialogText.title, "No Materials in selected folder to update.", DialogText.ok);
    280.                 return;
    281.             }
    282.          
    283.             if ((!Application.isBatchMode) && (!EditorUtility.DisplayDialog(DialogText.title, "The upgrade will overwrite materials in your project. " + DialogText.projectBackMessage, DialogText.proceed, DialogText.cancel)))
    284.                 return;
    285.          
    286.             int materialIndex = 0;
    287.             foreach (string path in materialPaths)
    288.             {
    289.                 materialIndex++;
    290.                 if (EditorUtility.DisplayCancelableProgressBar(progressBarName, string.Format("({0} of {1}) {2}", materialIndex, totalMaterialCount, path), (float)materialIndex / (float)totalMaterialCount))
    291.                     break;
    292.  
    293.                 Material material = AssetDatabase.LoadMainAssetAtPath(path) as Material;
    294.  
    295.                 if (!shaderNamesToIgnore.Contains(material?.shader?.name))
    296.                     Upgrade(material, upgraders, flags);
    297.             }
    298.  
    299.             EditorUtility.ClearProgressBar();
    300.         }
    301.  
    302.         private static bool TryGetSelectedDirectory(out string directoryPath)
    303.         {
    304.             directoryPath = AssetDatabase.GetAssetPath(Selection.activeObject.GetInstanceID());
    305.             if (string.IsNullOrEmpty(directoryPath)) return false;
    306.  
    307.             if (Directory.Exists(directoryPath)) return true;
    308.          
    309.             directoryPath = null;
    310.             return false;
    311.         }
    312.         #endregion
    313.     }
    314. }
    315. #endif
     
  11. Irrgeist

    Irrgeist

    Joined:
    Jul 9, 2015
    Posts:
    28
    Thanks, works waaaaay better than the new weird converter.

    The new converter is nice if you just want to bulk update everything. The converter needs an overhaul!