Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Native Plugins and Backward Compatibility

Discussion in 'Editor & General Support' started by stanislav-osipov, Mar 5, 2015.

  1. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Hello, I am developer of the Stans Assets plugins.
    Since Unity 5 is released, now I have to not only update my packages to work with Unity 5, but support older Unity versions as well. I have a few questions and wold be extremely appreciate if you will help me out.

    1) Unity5 is looking for plugin files (*.jar, *h, *.m, *.mm) all over the project. Even if I put this files into the Editor project, unity tries to include it to the project anyway. So is there is a possibility to tell unity ignore such files?

    2) How to link *.freamwork *.lib file to Xcode project automatically?
    3) I noticed that now Unity can add default frameworks to Xcode project. Is there is a way to control this via editor scripts? For example for older unity version I was used my own solution, and post process building script was looked like this:
    Code (CSharp):
    1. #if UNITY_IPHONE
    2.         string Accounts = "Accounts.framework";
    3.         if(!ISDSettings.Instance.frameworks.Contains(Accounts)) {
    4.             ISDSettings.Instance.frameworks.Add(Accounts);
    5.         }
    6.  
    7.  
    8.         string SocialF = "Social.framework";
    9.         if(!ISDSettings.Instance.frameworks.Contains(SocialF)) {
    10.             ISDSettings.Instance.frameworks.Add(SocialF);
    11.         }
    12.  
    13.         string MessageUI = "MessageUI.framework";
    14.         if(!ISDSettings.Instance.frameworks.Contains(MessageUI)) {
    15.             ISDSettings.Instance.frameworks.Add(MessageUI);
    16.         }
    17.  
    18.        string libafc = "libafc.dylib";
    19.         if(!ISDSettings.Instance.libs.Contains(libafc)) {
    20.             ISDSettings.Instance.libs.Add(libafc);
    21.         }
    22.  
    23.         #endif

    4) Due to new Unity policy Android resources should be packed in jars. So what the best way to provide Backward Compatibility for older Unity versions in this case.

    Thanks.
     
    XCO likes this.
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,658
    So these files are unused then, why are they in a project in the first place? Put them outside Assets folder.
     
  3. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Het @Tomas1856, thx for replay, I'll try to explain. Here is how it was working in older Unity versions

    For example I have android plugin with the billing part, which is stored to separated jar. If user want's to enable billing feature this jar is copied from:

    Assets/Plugins/StansAssets/Android/libs/an_billing.jar to Assets/Plugins/Android/libs/an_billing.jar
    In case user what's to disable billing (since it may be the conflict with another android billing plugins), he will simply uncheck billing checkbox, and Assets/Plugins/Android/libs/an_billing.jar will be removed. If he want's to enable it again. it will be copied.

    I can not put it outside of Assets folder, since this is Asset Store plugin, and all files are in *.unitypackage.
    for now I am using workaround, all jars which is not used have *.txt extension.

    By the way Unity Official Facebook SDK also uses this. it stores jars outside of Plugins folder, and copies it in post process.


    And here is the fun thing. If jar is Under Editor folder, it's will not be considered by unity as JAR, which is great since Editor folder means it's Editor only assets, and shouldn't be added to the build.
    The fun thing is that Unity tries to include in the build (*h, *.m, *.mm) files and Android res event if it's inside Editor folder.

    But actually, If for the rest of listed issues I can implement workaround. I do not know how to deal with this:
     
  4. XCO

    XCO

    Joined:
    Nov 17, 2012
    Posts:
    377
    You are the Man, STAN THE MAN!! :)
     
  5. bitter

    bitter

    Unity Technologies

    Joined:
    Jan 11, 2012
    Posts:
    530
    Unity 5 will still support resources in the plugins folder but going forward you should put any resources you have in an Android Library (not a jar file). Actually any plugin that relies on manifest changes and/or has resources should be done as an Android library. "Android Library Projects" have been supported since Unity 4.2 and In Unity 5.0 we added support for AAR files. Personally I prefer AAR files but if you need to be backwards compatible I would suggest using regular Android Library Project folders.
     
  6. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Got it, so looks like I have to migrate to the "Android Library Projects". Since look slike Unity will drop to support resources in the plugins folder in future releases.
    Thx for straight forward answer.