• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by a96andrei · Mar 23, 2017 at 03:23 PM · buildandroid buildpluginsandroidpluginbuildpipeline

Change Plugin platforms by scripting

I am making an Android game for both Google Play Store and Amazon Store.

I am using a user-defined scripting symbol "UNITY_AMAZON" and pre-processing to do the store specific scripting, but I also need to exclude some plugins when building for each target. I don't want some of the play-services .arr files in the Amazon build and I don't want the Amazon .jars in the GooglePlay build.

Of course, I can always manually select and deselect the files I want from the editor. I am asking if t$$anonymous$$s can be done by scripting to automate the process as there are quite many files to change.

Comment

People who like this

0 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image

Answer by Claytonious · Nov 21, 2017 at 05:17 PM

Yes. Get its importer and then change settings on that. For example, t$$anonymous$$s turns off the Android platform on a native library:

 ((PluginImporter)PluginImporter.GetAtPath("Assets/Plugins/Android/libs/armeabi-v7a/libovrplatformloader.so")).SetCompatibleWithPlatform(BuildTarget.Android, false);
Comment
superbcorperation
FlorianBernard
silentmaster

People who like this

3 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by adarshnambiar · Mar 23, 2017 at 07:34 PM

I found some related discussion Check t$$anonymous$$s if you haven't

Comment

People who like this

0 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image a96andrei · Mar 24, 2017 at 01:32 PM 0
Share

Thank you, I couldn't find that discussion by myself. From what I've read there, I understand that there is no built-in way to do what I need. I will come back with an answer after I implement a workaround. I'm thinking about storing every file's path/name in an editor script that will move them to another folder before the build starts and after that, it will restore the files to their original directory.

avatar image

Answer by SohailBukhari · Mar 24, 2017 at 01:47 PM

@username

You have to adjust the settings on the library asset in the inspector to choose on w$$anonymous$$ch platform(s) t$$anonymous$$s library should be included and used.

See Platform Selection Image


capture.png (28.6 kB)
Comment

People who like this

0 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image a96andrei · Mar 24, 2017 at 02:03 PM 0
Share

I know this. But I need to change a lot of files. Imagine having to do this manually for 20 files in multiple folders per platform per build. Chances to miss something are really high. My question is if this can be done by scripting. For example, make a list of files and then set them to be included in Android if certain conditions are met.

avatar image

Answer by xLeo · May 05, 2021 at 06:13 PM

@a96andrei: We use t$$anonymous$$s code to disable plugins like Firebase (since some features depend on Google Play Services):

     public static void ToggleFirebaseRemoteConfigDependencies(bool supportsGooglePlayServices)
     {
         Debug.LogFormat("[ToggleFirebaseRemoteConfigDependencies]  Platform supports Google Play Services: {0}", supportsGooglePlayServices);
         
         const string remoteConfigPath = "Assets/Firebase/Plugins/Firebase.RemoteConfig.dll";
         TogglePluginEnabledOrDisabled(remoteConfigPath, supportsGooglePlayServices, BuildTarget.Android);
     }


     private static void TogglePluginEnabledOrDisabled(string filePath, bool enableFile, BuildTarget buildTarget)
     {
         var pluginImporter = AssetImporter.GetAtPath(filePath) as PluginImporter;

         if (!pluginImporter)
         {
             Debug.LogWarningFormat("[TogglePluginEnabledOrDisabled] Aborting: Couldn't find plugin importer for File Path: {0}", filePath);
             return;
         }
         
         pluginImporter.SetCompatibleWithPlatform(buildTarget, enableFile);
         EditorUtility.SetDirty(pluginImporter);
         pluginImporter.SaveAndReimport();
         
         Debug.LogFormat("[TogglePluginEnabledOrDisabled] Target State: {0}; Platform: {1}; File Path: {2}",
             enableFile, buildTarget, filePath);
     }
Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Custom Pre Build Process? 4 Answers

Build to Android with a Wireless connection? 1 Answer

Distribute terrain in zones 3 Answers

Is it possible to set android sdk path via script? 1 Answer

Unity Android App closed suddenly 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges