Hi,
in Unity 5, the materials in inspector are folded by default, like this:
Is there a way to make all materials unfolded by default?
I’ve tried to write custom editor with something like this, but it doesn’t work with MaterialEditor.
Hi,
in Unity 5, the materials in inspector are folded by default, like this:
Is there a way to make all materials unfolded by default?
I’ve tried to write custom editor with something like this, but it doesn’t work with MaterialEditor.
This script will open all materials in inspector on Ctrl + H.
Edit: Optimized and shortcut-ed version.
using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
public class UnfoldMaterials
{
private static FieldInfo isVisible = typeof(MaterialEditor).GetField("m_IsVisible", BindingFlags.NonPublic | BindingFlags.Instance);
private static Type inspectorWindowType = typeof(EditorWindow).Assembly.GetType("UnityEditor.InspectorWindow");
[MenuItem("GameObject/Unfold Material %H")]
private static void Unfold()
{
var editors = Resources.FindObjectsOfTypeAll<MaterialEditor>();
if (editors.Length == 0)
return;
for (int i = 0; i < editors.Length; i++)
UnfoldMaterials.isVisible.SetValue(editors*, true);*
EditorWindow[] inspectors = Resources.FindObjectsOfTypeAll(UnfoldMaterials.inspectorWindowType) as EditorWindow[];*
for (int i = 0; i < inspectors.Length; i++)*
_ inspectors*.Repaint();_
_ }_
_}*_