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

Prevent stripping of my ENTIRE Assembly-CSharp assembly?

Discussion in 'iOS and tvOS' started by techmage, Jan 8, 2015.

  1. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    So I want to prevent stripping of my entire Assembly-CSharp. How do I do that?

    Does this do the thing?

    Code (CSharp):
    1. <linker>
    2.        <assembly fullname="UnityEngine">
    3.                <type fullname="UnityEngine.Animator" preserve="all"/>
    4.        </assembly>
    5.      
    6.        <assembly fullname="Assembly-CSharp">
    7.                <type fullname="*" preserve="all"/>
    8.        </assembly>            
    9. </linker>
    10.  
     
  2. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    Also I kind of just want to include everything under the UnityEngine namespace no matter what... How do I do that?

    just

    <type fullname="UnityEngine" preserve="all"/>

    seem to not do it

    and

    <type fullname="UnityEngine.*" preserve="all"/>

    gives an error
     
  3. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Hmm... I'm not sure how you'd go about it... the problem is that your Monobehaviors and I think stuff inside the UnityEngine assembly don't have a namespace (which technically means they are in the global namespace). What is getting stripped out of UnityEngine?
     
  4. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    I am doing this somewhat peculiar thing, which is needed, but I don't want to go into to much detailing.

    But basically I am building the app with an 'empty' scene that has nothing in it. Then loading in ALL my content, and all my levels through AssetBundles. So if I have build stripping enabled, then literally no loaded levels work as everything got stripped. So I kind of wanted it to force it to keep everything in my assembly, everything in UnityEngine and just strip out the stuff in System and use micro mscorlib.
     
  5. snlehton

    snlehton

    Joined:
    Jun 11, 2010
    Posts:
    99
    So you want stripping enabled but prevent stripping of some scripts?

    You probably have a loader scene in your project. What if you add a script there that references all the scripts you need to retain? Something like

    Code (CSharp):
    1. public class Ref : MonoBehaviour
    2. {
    3.     public MyScript1 a;
    4.     public MyScript2 b;
    5.     public MyScript3 c;
    6. ....
    7. }
    Make sure that Ref is placed in some GameObject on the loader scene. And you don't need to put anything into those fields, they're just there to have dependency on the scripts...

    Shouldn't that prevent those scripts being stripped?

    Cheers,
    Sampsa
     
  6. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    You still have to be somewhat careful. I've seen properties even get stripped even though a class remains.
     
  7. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    I've taken to just having a dummy scene with every components and class put in it that gets included in the build....