facebook twitter hatena line email

「Unity/Addressable」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(Addressableの作り方)
(Addressableの作り方)
行36: 行36:
 
}
 
}
 
</pre>
 
</pre>
 +
 +
==設定確認==
 +
#Unityメインメニュー/Window/Addressable/Groups/Profile/ManageProfiles
 +
<pre>
 +
BuildTarget:[UnityEditor.EditorUserBuildSettings.activeBuildTarget]
 +
LocalBuildPath:[UnityEngine.AddressableAssets.Addressables.BuildPath]/[BuildTarget]
 +
LocalLoadPath:{UnityEngine.AddressableAssets.Addressables.RuntimePath}/[BuildTarget]
 +
RemoteBuildPath:ServerData/[BuildTarget]
 +
RemoteLoadPath:http://localhost/[BuildTarget]
 +
</pre>
 +
 +
===設定変更===
 +
設定変更したい場合は、
 +
#Unityメインメニュー/Window/Addressable/Groups//ManageProfiles/Create/NewProfileを選択し、
 +
#各項目を入力していく
  
 
==Addressableの削除==
 
==Addressableの削除==

2021年7月30日 (金) 22:54時点における版

Addressableとは

外部サーバーで使えるResources

インストール

  1. Unityメインメニュー/Window/Package Manager/Unity Registryが選択"addressable"を検索
  2. Addressablesをinstall

Addressableの作り方

  1. 適当にプレハブをAssetsの下につくる。
  2. inspectorにaddressableのチェックがあるので、チェックを付ける
  3. チェックをつけると、addressableのpathが生成される(例:Assets/ButtonGroup.prefab)
  4. 作られたファイルをResources以外のdirに入れる。(例:Resources_addressable)
  5. 以下SampleScene.csをシーンに連携する
using System.Collections;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
public class SampleScene : MonoBehaviour
{
    void Start()
    {
        StartCoroutine(Load());
    }
    IEnumerator Load()
    {
        // プレハブ:GameObject、画像:Image、スプライト:Sprite
        var handle = Addressables.LoadAssetAsync<GameObject>("ButtonGroup");
        yield return handle;
        if (handle.Status == AsyncOperationStatus.Succeeded)
        {
            var instance = Instantiate(handle.Result);
        }
    }
}

設定確認

  1. Unityメインメニュー/Window/Addressable/Groups/Profile/ManageProfiles
BuildTarget:[UnityEditor.EditorUserBuildSettings.activeBuildTarget]
LocalBuildPath:[UnityEngine.AddressableAssets.Addressables.BuildPath]/[BuildTarget]
LocalLoadPath:{UnityEngine.AddressableAssets.Addressables.RuntimePath}/[BuildTarget]
RemoteBuildPath:ServerData/[BuildTarget]
RemoteLoadPath:http://localhost/[BuildTarget]

設定変更

設定変更したい場合は、

  1. Unityメインメニュー/Window/Addressable/Groups//ManageProfiles/Create/NewProfileを選択し、
  2. 各項目を入力していく

Addressableの削除

  1. Window/Asset Management/Addressables/Groups
  2. Build/CleanBuild/AllとContent BuildersとBuild Pipeline Cache

Addressableの再生成

  1. Window/Asset Management/Addressables/Groups
  2. Build/New Build/Default Build Script

プロジェクト以下/ServerData/WebGL/とかにできる

ServerData/WebGL/catalog_v1.0.hash
ServerData/WebGL/catalog_v1.0.json
ServerData/WebGL/localization-assets-shared_assets_all.bundle
ServerData/WebGL/localization-string-tables-chinese(traditional)(zh-tw)_assets_all.bundle
ServerData/WebGL/localization-string-tables-english(unitedstates)(en-us)_assets_all.bundle
ServerData/WebGL/localization-string-tables-japanese(japan)(ja-jp)_assets_all.bundle

AddressablesのRemoteLoadPathの変更

  1. Window/Asset Management/Addressables/Groups
  2. Profile:WebGLを選択
  3. ManageProfiles
  4. RemoteLoadPathを変更する

https://qiita.com/tetr4lab/items/1b26755089820b041b4f

参考

https://robamemo.hatenablog.com/entry/2021/01/08/195415

https://light11.hatenadiary.com/entry/2020/07/29/202755