13 [CustomPropertyDrawer(typeof(OpenLocalFileAttribute))]
16 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
18 if (property.propertyType != SerializedPropertyType.String)
20 throw new ArgumentException();
24 EditorGUI.PropertyField(position, property, label);
26 position.x += position.width;
27 position.width = 30.0f;
29 if (GUI.Button(position,
"..."))
31 var path = EditorUtility.OpenFilePanel(
"Select a file", Application.dataPath,
"");
32 if (
string.IsNullOrEmpty(path))
37 if (path.StartsWith(Application.dataPath))
39 path = path.Substring(Application.dataPath.Length);
40 path = path.Replace(
"/",
"\\");
43 property.stringValue = path;