Search Unity

Feedback Impossible to write custom BuildScriptPackedMode

Discussion in 'Addressables' started by Kamyker, Oct 17, 2020.

  1. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
    Impossible without changing Addressables source as ContentUpdateContext and RevertUnchangedAssetsToPreviousAssetState are inaccessible...

    Additionally why static methods are so overused there??? Why not
    protected virtual
    to make it easily extensible?
     
    LuGus-Jan and einWikinger like this.
  2. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
    There's more:
    Code (CSharp):
    1. internal IBuildLogger m_Log;
    2. ProjectConfigData
    3. BuildLayoutGenerationTask
    4. buildLayoutTask.m_BundleNameRemap
    It wasn't the case few patches ago. There were no internal types used.
     
    LuGus-Jan and einWikinger like this.
  3. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,822
    Hey there! Happy to bounce this feedback off of the team, and relay any insight they have.
     
    einWikinger and Kamyker like this.
  4. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    763
    I'll bring this up with the team. This is definitely something that should be possible.
     
  5. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
    My use case is to simply build Addressable Group to one folder to make modding possible. Later on content is read from a folder of Steam Workshop item and catalog.json.

    No idea if there's better way but I'm currently using modified BuildScriptPackedMode (had to make addressables package embedded). Only thing that's missing is .hash file.
    https://gist.github.com/kamyker/a56e05d051807c9b6af94a05a2a7de6b/revisions
     
  6. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
    Found better way to build Group as remote one, the only problem left is error when loading them with Addressables.LoadContentCatalogAsync

    Code (CSharp):
    1. internal ResourceLocationBase CreateCatalogLocationWithHashDependencies( string catalogPath, string hashFilePath )
    2. {
    3.     ResourceLocationBase resourceLocationBase = new ResourceLocationBase(catalogPath, catalogPath, typeof(ContentCatalogProvider).FullName, typeof(IResourceLocator));
    4.     if ( !string.IsNullOrEmpty( hashFilePath ) )
    5.     {
    6.         string text = ResolveInternalId("{UnityEngine.Application.persistentDataPath}/com.unity.addressables/" + Path.GetFileName(hashFilePath));
    7.         resourceLocationBase.Dependencies.Add( new ResourceLocationBase( hashFilePath, hashFilePath, typeof( TextDataProvider ).FullName, typeof( string ) ) );
    8. //this below gives errors, could be fixed with if(File.Exists(text))
    9.         resourceLocationBase.Dependencies.Add( new ResourceLocationBase( text, text, typeof( TextDataProvider ).FullName, typeof( string ) ) );
    10.     }
    11.     return resourceLocationBase;
    12. }
    Other than that error everything works fine, I've tried to copy/paste local .hash file to
    UnityEngine.Application.persistentDataPath}/com.unity.addressables/" + Path.GetFileName(hashFilePath)
    but then it stops working at all.
     
  7. LuGus-Jan

    LuGus-Jan

    Joined:
    Oct 3, 2016
    Posts:
    179
    I'd like to chime in on this topic since I'm trying to write a custom Packed-mode script as well. There's too much using
    internal
    -protection modifiers which doesn't allow to properly extend or build your own packing scripts, as well as inconsistent methods of which I expect to be protected virtual but are either
    internal
    or
    private
    .

    For example, I'd like to override the
    DoBuild
    -method, and actually keep most of its functionality intact by copying the contents of the base function with a few additions of my own, but can't because a lot of the stuff isn't accessible.