13 [CustomPropertyDrawer(typeof(SaveLocalFileAttribute))]
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.SaveFilePanel(
"Select a file", Application.dataPath,
"",
"");
32 if (
string.IsNullOrEmpty(path))
37 if (path.StartsWith(Application.dataPath))
39 path = path.Substring(Application.dataPath.Length);
42 property.stringValue = path;