PostProcessBuild Script, file path of script?

Hi all,

I am currently working on a plugin for Unity. The plugin is for iOS and and is essentially a library to eventually embed in the built product. The library contains a .storyboard file. It seems unity doesn’t copy .storyboard files into the Xcode project together with the other library files (currently .h and .mm). So I figured I need to copy into the final Xcode project through PostProcessBuild script.

However I cannot seem to find a good way to get a relative file path to my post process build script or similar. The script is located in an Editor folder and on the same level I have the iOS folder, where the .storyboard file is located with the rest of the plugin files. I was hoping I could do something like “…/iOS/MyStoryboard.storyboard”, but I can’t seem to find a way.

My current solution is using Application.dataPath, which gets me to the root of the Assets folder, but I feel this is still fragile, as I may not know exactly where a developer would place my plugin.

I am an iOS developer and completely new to Unity, maybe it’s the wrong approach?

Any ideas?

Thanks you in advance.

If you distribute your plugin by the Package Manager, it should always be in a reliable spot relative to the project root.

But if you prefer, I think you could use a reference to the storyboard item to query the Unity AssetDatabase as to where it actually is filesystem-wise, perhaps something like:

https://docs.unity3d.com/ScriptReference/AssetDatabase.GetAssetPath.html

Hi Kurt,

Thanks you for your reply. Will definitely try that out. Seems like exactly the thing I am looking for. Your comment on the package manager is also valid I will look into this as well. The plugin will be distributed as part of a larger package delivering plugin for both iOS and Android as well as C# wrappers. But I guess, still, the path would be stable.

Thanks for your input,
Mikkel