/// <summary>
        /// Popup Shader selector that mimics the material shader popup in the material header
        /// </summary>
        /// <param name="material">The material that is the parent of the shader for popup.</param>
        /// <param name="materialArray">Material array the shader popup operates on.</param>
        public static void ShaderPopup(Material material, MaterialArray materialArray)
        {
            var index = Array.FindIndex(shaderNames, s => s == material.shader.name);

            // Have to use our own popup since you cannot use the material editor popup
            if (index < 0 || index > shaderNames.Length)
            {
                UpdateShaderNames(material);
                EditorGUILayout.Popup(index, shaderNameGUIContents);
                return;
            }
            index = EditorGUILayout.Popup(index, shaderNameGUIContents);
            if (shaderNames[index] != material.shader.name)
            {
                var matSerial = new SerializedObject(material);
                matSerial.Update();

                var shaderSerial = matSerial.FindProperty("m_Shader");
                shaderSerial.objectReferenceValue = Shader.Find(shaderNames[index]);
                matSerial.ApplyModifiedProperties();

                MultiMaterialEditorUtilities.SetCheckMaterialShaders(materialArray, material);
            }
        }
        /// <summary>
        /// Draw the Multi Material Inspector GUI using Material Editors for each material in Material Array
        /// </summary>
        /// <param name="serializedObject">Target serialized object from the inspector</param>
        /// <param name="materialArray">Material array to be used in inspector</param>
        /// <param name="materialEditors">Material Editors for each material in materialArray</param>
        /// <param name="changed">Editor property changed from outside of this method</param>
        /// <param name="materialProperties">Array of serialized properties that are the materials in the Material
        /// Array. Used for property drawer in material header</param>
        public static void OnInspectorGUI(SerializedObject serializedObject, MaterialArray materialArray,
                                          ref MaterialEditor[] materialEditors, bool changed = false, SerializedProperty[] materialProperties = null)
        {
            var materialEditorReady = true;

            if (changed || !CheckMaterialEditors(materialEditors, materialArray))
            {
                materialEditorReady = RebuildMaterialEditors(ref materialEditors, materialArray) &&
                                      Event.current.type == EventType.Layout;
            }

            if (materialEditorReady)
            {
                for (var i = 0; i < materialEditors.Length; i++)
                {
                    if (materialArray.materials[i] != null && materialEditors[i] != null)
                    {
                        var material = materialEditors[i].target as Material;

                        OnMiniMaterialArrayHeaderGUI(serializedObject, ref materialEditors[i], materialArray,
                                                     materialProperties != null && materialProperties.Length > i &&
                                                     materialProperties[i] != null? materialProperties[i] : null);

                        EditorGUI.BeginDisabledGroup(material != null && material.name == k_DefaultMaterial);
                        // Draw the Material Editor Body
                        if (materialEditors[i].isVisible)
                        {
                            EditorGUI.BeginChangeCheck();
                            if (GUILayout.Button("Sync to Material"))
                            {
                                MultiMaterialEditorUtilities.UpdateMaterials(materialArray, material, true);
                            }
                            materialEditors[i].OnInspectorGUI();

                            if (EditorGUI.EndChangeCheck())
                            {
                                MultiMaterialEditorUtilities.UpdateMaterials(materialArray, material);
                            }
                        }
                        EditorGUI.EndDisabledGroup();
                    }
                    else
                    {
                        if (materialProperties != null)
                        {
                            EditorGUI.BeginChangeCheck();
                            materialProperties[i].serializedObject.Update();
                            EditorGUILayout.PropertyField(materialProperties[i], new GUIContent("Material"));
                            materialProperties[i].serializedObject.ApplyModifiedProperties();
                            if (EditorGUI.EndChangeCheck())
                            {
                                RebuildMaterialEditors(ref materialEditors, materialArray);
                            }
                        }
                        else
                        {
                            EditorGUILayout.LabelField(k_NullMaterialWarning, s_RichTextStyle);
                        }
                    }
                }
            }
        }