Merge pull request #203 from dwango/santarh/fix_uniunlit_inspector_cull_mode_bug

Fix UniUnlit inspector's bug, cull mode was empty.
This commit is contained in:
ousttrue
2019-02-28 03:25:34 +09:00
committed by GitHub

View File

@@ -124,14 +124,24 @@ namespace UniGLTF.UniUnlit
private static bool PopupEnum<T>(string name, MaterialProperty property, MaterialEditor editor) where T : struct
{
if (!typeof(T).IsEnum) return false;
EditorGUI.showMixedValue = property.hasMixedValue;
EditorGUI.BeginChangeCheck();
var ret = EditorGUILayout.Popup(name, (int) property.floatValue, Enum.GetNames(typeof(T)));
var values = (T[]) Enum.GetValues(typeof(T));
var names = Enum.GetNames(typeof(T));
var currInt = (int) property.floatValue;
var currValue = (T) Enum.ToObject(typeof(T), currInt);
var currIndex = Array.IndexOf(values, currValue);
var nextIndex = EditorGUILayout.Popup(name, currIndex, names);
var changed = EditorGUI.EndChangeCheck();
if (changed)
{
editor.RegisterPropertyChangeUndo("EnumPopUp");
property.floatValue = ret;
var nextValue = values[nextIndex];
var nextInt = (int) (object) nextValue;
property.floatValue = nextInt;
}
EditorGUI.showMixedValue = false;
return changed;