Search Unity

Is it possible to exclude Assets depending the target platform ?

Discussion in 'Scripting' started by bali33, Jul 29, 2015.

  1. bali33

    bali33

    Joined:
    Aug 14, 2011
    Posts:
    232
    Hello,

    My current application plays video - depending the target platform I use MovieTexture or Handheld.PlayFullScreenMovie.

    I do manage, I think, to put all MovieTexture references into #if UNTY_STANDLONE block in order to avoid the following message :

    But now, when I try to compile for Android for instance, I have this error message :

    So the build failed and I don't know how to tell the build to exclude the Assets/videos folder - I don't even know if it's possible.

    Thank you.

    ps : is there a best practice when it comes to play video and targeting standalone and mobile platform ?
     
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,531
    Compile the assets into an AssetBundle, AssetBundles when built have a target platform set.

    Now, where you have code that is for your target platform that uses the AssetBundle (between the UNITY_STANDALONE lines). You load the AssetBundle and pull the assets out from it.
     
  3. bali33

    bali33

    Joined:
    Aug 14, 2011
    Posts:
    232
    Hi,

    It means that the application would have to load the asset bundle - so it will need an internet connection, is that right ?

    Thank you
     
  4. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,531
  5. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,089
    If you don't want to do that you can also do this: (bit hacky though)

    1) Do all your builds through a script using BuildPipeline.BuildPlayer

    2) In the script move any assets somewhere else before doing the build (using AssetDatabase.MoveAsset)

    3) Do the build and then move the assets back