Search Unity

Question Addressables: Building from editor directly to Google Cloud or similar services

Discussion in 'Addressables' started by HEROTECH70, May 3, 2021.

  1. HEROTECH70

    HEROTECH70

    Joined:
    May 24, 2017
    Posts:
    74
    I've been looking all over the web as well as experimenting on my own but since I couldn't find any tutorials or examples, I figured I'd ask here.

    What I want to do is to be able to build addressable assets from Unity directly onto a bucket on google cloud, without having to manually upload the files on my browser. I believe setting up a custom hosting service is the way to go if I've understood correctly, yet I haven't been able to figure out how to set up the script to do it.

    Any help would be greatly appreciated.
     
  2. HEROTECH70

    HEROTECH70

    Joined:
    May 24, 2017
    Posts:
    74
    bump, still struggling to achieve this. Any pointers or help?
     
  3. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
    You could always use google cli in a script that run after the addressable build to upload the bundle.
    Would that work?
     
  4. HEROTECH70

    HEROTECH70

    Joined:
    May 24, 2017
    Posts:
    74
    Yeah, I've already figured out how to upload to the firebase cloud through scripts but the issue is that it wouldn't discern which assets have been updated and which haven't, wasting time unnecessarily uploading untouched assets.

    At the moment I'm trying to figure out where in the default build scripts it is determined which assets were updated in the build and somehow use that to selectively upload whatever has been updated.
     
  5. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
  6. HEROTECH70

    HEROTECH70

    Joined:
    May 24, 2017
    Posts:
    74
    No worries, I'm more than willing to use amazon instead if it means I can get this to work. Adding a missing file seems useful enough, but what about uploading the same file if it has been updated in the build?
     
  7. HEROTECH70

    HEROTECH70

    Joined:
    May 24, 2017
    Posts:
    74
    I'm reading up on the link. Using this sync function is possible to sync a local directory with the bucket?
     
  8. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
    Yes it would sync will make the two folder be the same. If a file was updated it will replace it

    Yes if it the same as amazon it work both way
     
  9. HEROTECH70

    HEROTECH70

    Joined:
    May 24, 2017
    Posts:
    74
    Okay, will give this a shot. Thanks a lot for the tips!
     
  10. HEROTECH70

    HEROTECH70

    Joined:
    May 24, 2017
    Posts:
    74
    Code (CSharp):
    1.     public void CycleThroughDirectory(string source)
    2.     {
    3.         string[] files = Directory.GetDirectories(source);
    4.         foreach (var file in files)
    5.         {
    6.             FileAttributes attributes = File.GetAttributes(file);
    7.  
    8.             if (attributes.HasFlag(FileAttributes.Directory))
    9.             {
    10.                 string[] originalSourceDir = sourceDirectory.Split('\\');
    11.                 string[] newDir = file.Split('\\');
    12.                 string extra = "";
    13.  
    14.                 for (int i = originalSourceDir.Length; i < newDir.Length; i++)
    15.                 {
    16.                     extra = extra + "/" + newDir[i];
    17.                 }
    18.  
    19.                 SyncFolder(file, targetDirectory + extra, arguments);
    20.                 CycleThroughDirectory(file);
    21.             }
    22.         }
    23.     }
    24.  
    25.  
    26.  
    27.     public void SyncFolder(string source, string target, string argumentsGiven = "")
    28.     {
    29.         Debug.Log("synching " + source);
    30.         string strCmdText;
    31.         if (argumentsGiven == string.Empty)
    32.         {
    33.             strCmdText = "/C gsutil rsync " + source + " " + target;
    34.         }
    35.         else
    36.         {
    37.             strCmdText = "/C gsutil rsync " + argumentsGiven + " " + source + " " + target;
    38.         }
    39.         System.Diagnostics.Process.Start("CMD.exe", strCmdText);
    40.     }

    Just a quick follow up, using the gsutil SDK I've managed to automate the process through this script. I post it here in case anyone finds it useful or if someone finds flaws in this
     
    EmilieCollard191 likes this.