Hi everyone,
We have a project that makes different applications for different platforms.
- AR application
- Hololens application
- Oculus application
And we want to make use of Unity Cloud Build to speed up the building process, this means switching between the different platforms by script.
We added PLATFORM_OCULUS constraint to the all Oculus Integration SDK “Assembly Definition Assets”, and to all scripts that depends on this.
Everythings works! That is if I delete the Oculus Integration SDK directory by hand and restart Unity.
We are running this script before the build (IPreprocessBuildWithReport):
public void ExludeFolders()
{
foreach(var dirPath in configuration.DirectoriesToExlude)
{
#if UNITY_CLOUD_BUILD
var isRemoved = AssetDatabase.DeleteAsset(dirPath);
if(isRemoved)
{
Debug.Log("Removed: " + dirPath);
}
else
{
throw new BuildFailedException("NOT Removed: " + dirPath);
}
#else
if(!dirPath.Contains("~"))
{
var dirName = dirPath.Split('/').Last();
var error = AssetDatabase.RenameAsset(dirPath, dirName + "~");
if(!string.IsNullOrEmpty(error))
{
throw new BuildFailedException("Unable to exclude folder: "+dirName+"! Restarting helps.");
}
Debug.Log("Hide folder: " + dirPath);
}
#endif
}
AssetDatabase.Refresh();
}
This works:
- Remove Oculus directory by hand in the editor
- Re-open Unity
- Build APK + obb
- build no errors
- Everything works!
This doesn’t:
- Run the build with pre-build script on Editor or Unity Cloud Build (both same result)
- Build APK + obb
- build no errors
- APK crash on start-up! (also iOS)
The build crashes at start-up at this line, when the folder is deleted by script:
var prefabResource = Resources.Load(resourcePath);
(The crash isn’t send to Unity Cloud Build, its a hard crash)
This happens (I think) because of native plugins, they are loaded into memory and makes my build crash on start-up. It makes my .obb corupted and crashes when I do a Resources.Load call.
(I have reproduced this multiple times)
So I have two question:
- Am I right that this is because the native plugins loaded into memery before I make a build? Or something else that is still in memory…
- How can I stop Oculus for loading these native plug-ins/stuff before I run this on Unity Cloud Build? I want to exclude the Oculus directory when I add PLATFORM_OCULUS in the scripting define symbols.