public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor) { if (!MaterialKeywordEnumDrawer.IsPropertyTypeSuitable(prop)) { return(40f); } return(base.GetPropertyHeight(prop, label, editor)); }
public override void Apply(MaterialProperty prop) { base.Apply(prop); if (!MaterialKeywordEnumDrawer.IsPropertyTypeSuitable(prop) || prop.hasMixedValue) { return; } this.SetKeyword(prop, (int)prop.floatValue); }
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor) { float result; if (!MaterialKeywordEnumDrawer.IsPropertyTypeSuitable(prop)) { result = 40f; } else { result = base.GetPropertyHeight(prop, label, editor); } return(result); }
private void SetKeyword(MaterialProperty prop, int index) { for (int index1 = 0; index1 < this.keywords.Length; ++index1) { string keywordName = MaterialKeywordEnumDrawer.GetKeywordName(prop.name, this.keywords[index1]); foreach (Material target in prop.targets) { if (index == index1) { target.EnableKeyword(keywordName); } else { target.DisableKeyword(keywordName); } } } }
public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor) { if (!MaterialKeywordEnumDrawer.IsPropertyTypeSuitable(prop)) { GUIContent label2 = EditorGUIUtility.TempContent("KeywordEnum used on a non-float property: " + prop.name, EditorGUIUtility.GetHelpIcon(MessageType.Warning)); EditorGUI.LabelField(position, label2, EditorStyles.helpBox); return; } EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = prop.hasMixedValue; int num = (int)prop.floatValue; num = EditorGUI.Popup(position, label, num, this.keywords); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { prop.floatValue = (float)num; this.SetKeyword(prop, num); } }
private void SetKeyword(MaterialProperty prop, int index) { for (int i = 0; i < this.keywords.Length; i++) { string keywordName = MaterialKeywordEnumDrawer.GetKeywordName(prop.name, this.keywords[i].text); UnityEngine.Object[] targets = prop.targets; for (int j = 0; j < targets.Length; j++) { Material material = (Material)targets[j]; if (index == i) { material.EnableKeyword(keywordName); } else { material.DisableKeyword(keywordName); } } } }
public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor) { if (!MaterialKeywordEnumDrawer.IsPropertyTypeSuitable(prop)) { GUIContent label1 = EditorGUIUtility.TempContent("KeywordEnum used on a non-float property: " + prop.name, (Texture)EditorGUIUtility.GetHelpIcon(MessageType.Warning)); EditorGUI.LabelField(position, label1, EditorStyles.helpBox); } else { EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = prop.hasMixedValue; int floatValue = (int)prop.floatValue; int index = EditorGUI.Popup(position, label, floatValue, this.keywords); EditorGUI.showMixedValue = false; if (!EditorGUI.EndChangeCheck()) { return; } prop.floatValue = (float)index; this.SetKeyword(prop, index); } }