# How can I expose a property to Unity that should be treated like an asset path?

I want to be able to do something like this:

public FileInfo XmlBehaviourFile;


And then use the asset browser in the Unity editor to select an asset. Ideally, I would like to limit it to XML files but that isn't too important.

I am aware of TextAsset but I can only access either a string or byte array of the contents. I can probably make this work, but at the moment, my library takes a FileInfo and handles the reading itself.

Is there a Type I can use that will make Unity let me choose a file in the editor and then simply store the path (ideally, it would handle making sure the path is relative and including the asset in the build).

Alternatively, would it be possible to write such a type that would work, I've not extended Unity, but I am aware it is possible.

• you can't serialize and expose directly a FileInfo. Btw, since what you need is a path you can expose a string and write a custom property drawer forcing the inspector to open a file browser. – Heisenbug Dec 9 '13 at 14:06
• The latter suggestion sounds exactly like what I need, I shall look in to custom property drawers – T. Kiley Dec 9 '13 at 14:09