Search Unity

Custom package (npm) containing streamingasset content

Discussion in 'Package Manager' started by LPhilipp, Oct 25, 2019.

  1. LPhilipp

    LPhilipp

    Joined:
    Apr 27, 2018
    Posts:
    15
    Hi,

    I wonder if this is possible. I tried with StreamingAsset Folder inside package root and inside Runtime folder but it did not work.

    Thanks
    Philipp
     
  2. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    756
    Hi @LPhilipp ,

    The StreamingAsset feature doesn't work within a package. This is intentional because it has many issues in this context. We recommend you use addressable instead.

    Regards,

    Pascal
     
  3. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    247
    1) Can we combine packages with addressables for content like that? Or do you mean we should download them just like AssetBundles through a REST API for example and use them afterwards?
    2) I'm using the StreamingAssets folder for configuration files which are automatically packaged when a build is issued but remain as text assets instead of being compiled into bundles(binary form). Is there a recommended way of including these files inside a package?
    3) I found out that Samples have functionality that allows you to import stuff at will(through UPM UI) inside a project. Any chance the same functionality be implemented for any type of package specific content that needs to be installed under Assets? In another thread it was being discussed that we need some way to deploy stuff without the bloat that scripts needs(e.g. see TextMeshPro or Cinemachine code). Any chance of getting another folder like Samples~ with things to add under Assets, verbatim, or perhaps a flag that defines whether such a deployment is optional or otherwise(done silently upon package installation)?
     
  4. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    756
    1) I'm not an expert with Addressable. I'm sorry. Here what the documentation says:
    2) I don't understand. I'm sorry.
    3) No plan for such a feature for the moment. Sorry.

    Looks like I'm not really helpful. Hopefully other community members will be more helpful!

    Regards,

    Pascal
     
  5. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    247
    1) I'll look into it. If Addressables don't get compiled into binary form anyway and I can call an Addressable from Packages I might be able to make it work.
    2) I have some json files that I want to be distributed as well. I'm using the fact that StreamingAssets folder will be propagated by default in a build(no extra code copying files after build finishes) and the files in there will not be compiled into bundles(as happens with other folders in a Unity project), thus they remain as text files in a build.
    My problem is that these configuration files have to do with a component that I recently moved to a custom package. At this point, my only way of installation is to include a static class with InitializeOnLoad which either generates or copies files under Assets which includes file existence/overwrite etc stuff which is an overhead.
    Is there a recommended way of handling such a situation? Will there be an API (e.g. OnPackageInstalled....) where you can include copy tasks etc but they only happen once when the package is installed. InitializeOnLoad happens everytime we open the project. Does it still make no sense?

    Basically my main issue is automation of post-package-installation tasks without the overhead of a custom editor window with Import actions and all the checks needed(like what TextMeshPro does for importing essentials which are needed anyway).
     
    UltraMunro and AdamBebko like this.
  6. gnp89

    gnp89

    Joined:
    Jun 25, 2012
    Posts:
    36
    hey @npatch were you able to make it work with Package+Addressables? I'm trying to make some content in the package addressable but I don't see any documentation about it, and some assets in my package show the addressable checkbox and others don't.
     
  7. npatch

    npatch

    Joined:
    Jun 26, 2015
    Posts:
    247
    No I didn't have time to dig into addressables.
    I ended up using UPM events and generating the StreamingAssets stuff(only configuration files) in code only at specific times(code runs only when you bother with UPM window or select the specific package in UPM).

    Just so it's clear, I have a couple of json files which I keep in StreamingAssets folder. If I build the app, this folder gets auto added in the output, so no extra code for me to deploy the jsons(e.g. create directories or copy files, after the build has ended). Also StreamingAssets doesn't compile its content into asset bundles like any other folder under Assets(except Plugins) would do. So the jsons remain humanly readable/editable even in the build itself. I wonder if @okcompute_unity understands better now.

    So I didn't have any express need to use addressables. UPM extension events were enough to have custom code running conditional deploy for my stuff. I just have to add this editor script along with the package and it just works. I try to do the bulk of work only on Added/Updated and Removed. OnSelected should be avoided as much as possible since if multiple package devs use it, UPM can end sluggish pretty fast.
     
    nirvanajie and marianomdq like this.
  8. AdamBebko

    AdamBebko

    Joined:
    Apr 8, 2016
    Posts:
    168
    I'm also curious about including addressables in a unity package. Or some other way to package resources in it
     
  9. Manumoi

    Manumoi

    Joined:
    Oct 31, 2014
    Posts:
    10
    Same for me, curious about ways to have resources (addressables?) within packages.
     
  10. UnityMaru

    UnityMaru

    Community Engagement Manager PSM

    Joined:
    Mar 16, 2016
    Posts:
    1,227
    Hey there,

    I've got some details from the team internally that may be of some use.

    Firstly, there is a "Assets in Packages" section in the Addressable documentation here which should help: https://docs.unity3d.com/Packages/c...eAssetsGettingStarted.html#assets-in-packages

    Secondly, there is this thread in the Addressable forums where users are figuring out how to use the feature with packages: https://forum.unity.com/threads/addressables-usage-within-a-package.1063016/#post-6874850

    Importing the Addressables Groups also works a bit differently whether if the Addressables package is already imported or not in the project at the time you're importing the groups.

    If you're importing Addressables Groups into a project with the Addressables package already installed, the Addressables Groups will be imported seamlessly (by an asset post processor probably)

    If you're importing Addressables groups into a project without the Addressables package, which you install post-facto, then you will have to drag n drop the Addressables Groups into the Addressables Settings Window (i havent tested this personally, but if you do try this and it doesn't work, then do let me know)
     
    AdamBebko likes this.