Quantcast
Channel: Questions in topic: "buildpipeline"
Viewing all articles
Browse latest Browse all 249

What's wrong with AssetBundles Build Pipeline & Conditional Compilation?

$
0
0
Hello there!
Here's an interesting situation:

I have a project with a modular structure. I've added the Mobile Notifications package to implement local push notifications. I have a module that implements iOS logic, and a module with implementation for Android. Modules swapped using conditional compilation depending on the target platform.

It looks like this: #if UNITY_EDITOR injectionBinder.Bind(); #elif UNITY_ANDROID injectionBinder.Bind(); #elif UNITY_IOS injectionBinder.Bind(); #endif
Everything work perfectly until I build AssetBundles: BuildPipeline.BuildAssetBundles(AssetBundlesDirectory, options, target);
I get several errors like this: error CS0234: The type or namespace name 'Notifications' does not exist in the namespace 'Unity' (are you missing an assembly reference?)
So the conditional compilation works fine in the Editor, but for AssetBundles something goes wrong. I thought the thing is in usings, so I put controller implementations in separate namespaces: #if UNITY_EDITOR injectionBinder.Bind().To(); #elif UNITY_ANDROID injectionBinder.Bind().To(); #elif UNITY_IOS injectionBinder.Bind().To(); #endif
Doesn't work.

The only thing that works is when I wrap the whole class body with #if: #if UNITY_ANDROID using System; using Modules.Config.Api; using Modules.Notifications.Api; using Unity.Notifications.Android; namespace Modules.Notifications.Impl.Android { public sealed class NotificationsControllerAndroid : INotificationsController { ... } } #endif
Any idea how it's resolvable besides wrapping the whole NotificationsControllerAndroid bonus in a #if? Many thanks!

Viewing all articles
Browse latest Browse all 249

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>