private void OpenConfiguration() { m_CurrentPanelView = PanelView.Configuration; if (m_MainCacheMaterials == null || m_CurrentMeshACIndex < 0 || m_CurrentMeshACIndex >= m_MainCacheMaterials.Count) { return; } Material mat = m_MainCacheMaterials[m_CurrentMeshACIndex]; Shader shader = mat.shader; if (ShaderMetaDataUtility.IsValidShader(shader)) { #pragma warning disable 0618 // Data conversion between Polybrush Beta and Polybrush 1.0. string path = ShaderMetaDataUtility.FindPolybrushMetaDataForShader(shader); if (!string.IsNullOrEmpty(path)) { ShaderMetaDataUtility.ConvertMetaDataToNewFormat(shader); } #pragma warning restore 0618 m_LoadedAttributes = ShaderMetaDataUtility.LoadShaderMetaData(shader); } }
/// <summary> /// Store the shader's attributes in the new format. /// Erase the .pbs.json on success. /// </summary> internal static void ConvertMetaDataToNewFormat(Shader shader) { if (shader == null) { throw new NullReferenceException("shader"); } string path = ShaderMetaDataUtility.FindPolybrushMetaDataForShader(shader); // If not null, it means we have data stored with the old format. // Proceed to conversion. if (path != null) { AttributeLayoutContainer attributesContainer = ScriptableObject.CreateInstance <AttributeLayoutContainer>(); ShaderMetaDataUtility.TryReadAttributeLayoutsFromJsonFile(path, out attributesContainer); if (attributesContainer != null) { ShaderMetaDataUtility.SaveShaderMetaData(shader, attributesContainer); FileUtil.DeleteFileOrDirectory(path); FileUtil.DeleteFileOrDirectory(path + ".meta"); AssetDatabase.Refresh(); } } }