Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Excluding scripts from build

Discussion in 'Scripting' started by TenHands, Aug 29, 2011.

  1. TenHands

    TenHands

    Joined:
    Mar 4, 2011
    Posts:
    67
    Is there any way to exclude certain scripts from a build? These certain scripts aren't refrenced anywhere, so I basically don't need them. Also I don't attach scripts dynamically. Thanks
     
  2. Ntero

    Ntero

    Joined:
    Apr 29, 2010
    Posts:
    1,436
    Code (csharp):
    1.  
    2. /*
    3. //PutStuffHere
    4. */
    5.  
    or if you only want to remove it for specific builds

    Code (csharp):
    1.  
    2. #if !Unity_IPhone
    3. //PutStuff Here
    4. #endif
    5.  
    Note: if you put #if TEST you can then later enable or disable TEST to be able to add remove it depending on the time.

    Otherwise you cannot remove code blocks like you can assets from a build, because it's all compiled to one .DLL and can't properly interpret your scene files to see how they are used/added.
     
  3. kablammyman

    kablammyman

    Joined:
    Nov 22, 2010
    Posts:
    507
    if you dont need them, why don't you delete the scripts? if you don't want to delete them, move them to another folder.
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    deactivate them.
     
  5. Ntero

    Ntero

    Joined:
    Apr 29, 2010
    Posts:
    1,436
    hippocoder,
    It's my understanding he is not talking about not using scripts already attached to objects, but rather removing script types from the executable as a whole. Could be wrong though.
     
  6. TenHands

    TenHands

    Joined:
    Mar 4, 2011
    Posts:
    67
    Ntero is right. I think I know how to comment code :)
     
  7. Ntero

    Ntero

    Joined:
    Apr 29, 2010
    Posts:
    1,436
    Sorry, I didn't mean to come off condescending (it's hard to determine experience level sometimes in here).

    But no, there is no advanced method (outside of Platform specific defines i.e #if/#endif) of restricting included scripts.
     
  8. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    You can add a folder called WebPlayerTemplates to your Assets folder and place any scripts you don't want compiled in there. The real purpose of this folder is to add (guess what) webplayer templates to your project but it is also a hack to take script files out of the project temporarily.