public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var pathProperty = property.FindPropertyRelative("_path"); var path = pathProperty.stringValue; var attrib = this.fieldInfo.GetCustomAttributes(typeof(ResourceLink.ConfigAttribute), false).FirstOrDefault() as ResourceLink.ConfigAttribute; var tp = (attrib != null && attrib.resourceType != null) ? attrib.resourceType : typeof(UnityEngine.Object); UnityEngine.Object asset = (!StringUtil.IsNullOrWhitespace(path)) ? Resources.Load(path, tp) : null; EditorGUI.BeginChangeCheck(); asset = SPEditorGUI.ObjectFieldX(position, asset, tp, false); if (EditorGUI.EndChangeCheck()) { if (asset == null) { pathProperty.stringValue = null; } else { path = this.GetPath(asset); if (!string.IsNullOrEmpty(path)) { pathProperty.stringValue = path; } } } }
private void _maskList_DrawHeader(Rect area) { var objArea = new Rect(area.xMin, area.yMin + 1f, area.width, EditorGUIUtility.singleLineHeight); //_objProp.objectReferenceValue = EditorGUI.ObjectField(objArea, _label, _objProp.objectReferenceValue, typeof(UnityEngine.Object), true); _objProp.objectReferenceValue = SPEditorGUI.ObjectFieldX(objArea, _label, _objProp.objectReferenceValue, typeof(UnityEngine.Object), true); }