Using Unity File and Directory Functions on Mac

I’m surprised I can’t find an answer to this question in the forums… but how does one use Directory and File operations on a Unity Editor script on a Mac?

It looks like both the Directory and File class inherit from Unity.Windows. When I try to include UnityEngine.Windows in my script, I get the error:
“The type or namespace name ‘Windows’ does not exist in the namespace.”

I’m assuming UnityEngine.Windows isn’t included/can’t work on a Mac. Then how can I write text files, create directories??

You don’t use Unity.Windows; use System.IO which works on all platforms (unless file access is restricted such as WebGL).

–Eric

1 Like

Why would this even be in the docs? I can’t build with it in 2022.3 LTS, either – not even on Windows.

error CS0234: The type or namespace name ‘Directory’ does not exist in the namespace ‘UnityEngine.Windows’ (are you missing an assembly reference?)

https://docs.unity3d.com/ScriptReference/Windows.File.html

https://docs.unity3d.com/ScriptReference/Windows.Directory.html

1 Like

I’m not seeing that mention where I found it at the top of Google.

EDIT: This appears to be a func of that class - since it’s grossly specific, every func under Directory really should really be disclaiming this. No one is going to think they’ll need to cascade down every single parent doc to check for rare, niche disclaimers that won’t generally exist elsewhere.