Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
2  
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.