//Assetbundleリスト専用のローダー public IEnumerator LoadAssetbundleListGo(LoadAssetbundleListCallBack callback) { // キャッシュシステムの準備が完了するのを待ちます while (!Caching.ready) { yield return(null); } //TODO 後で修正 int assetVersion = 0; //int assetVersion = DataManager.Instance.asset_version; //Debug.Log ("####### LoadAssetbundleList Ver :" + assetVersion ); int version = assetVersion; AssetBundleData assetBundleData; // string resultUrl = "file://" + SystemSetting.GetStreamingAssetspath() + SystemSetting.GetAdminAssetListPath () + SystemSetting.GetDataListName () + "."+DEFINE.ASSET_BUNDLE_PREFIX+".unity3d"; EditPlayerSettingsData data = ConfigManager.instance.GetEditPlayerSettingsData(); string resultUrl = data.m_strS3Url + Define.ASSET_BUNDLES_ROOT + SystemSetting.GetAdminAssetListPath() + SystemSetting.GetDataListName() + ".unity3d"; //Debug.Log ("Loading :"+m_strLoadURL); Debug.Log("LoadAssetbundleListGo:" + resultUrl); // 同じバージョンが存在する場合はアセットバンドルをキャッシュからロードするか、またはダウンロードしてキャッシュに格納します。 using (WWW www = WWW.LoadFromCacheOrDownload(resultUrl, version)) { yield return(www); if (www.error != null) { throw new Exception("WWWダウンロードにエラーがありました:" + www.error); } AssetBundle bundle = www.assetBundle; GameObject tmpObj = Instantiate(bundle.LoadAsset(SystemSetting.GetDataListName(), typeof(GameObject))) as GameObject; AssetBundleDataHolder assetBundleDataHolder = tmpObj.GetComponent <AssetBundleDataHolder>(); assetBundleData = assetBundleDataHolder.assetBundleData; if (tmpObj == null) { Debug.LogError("アセットバンドルList内容に異常があります"); } tmpObj.transform.parent = DataContainer.Instance.gameObject.transform; // メモリ節約のため圧縮されたアセットバンドルのコンテンツをアンロード bundle.Unload(false); } callback(assetBundleData); }
//プレハブを作ってスクリプタブルオブジェクトをアタッチするところまで. public static void CreateComponents(Type _type) { string name = "target"; string outputPath = SystemSetting.GetAssetBundleListPath() + "Prefab.prefab"; GameObject gameObject = EditorUtility.CreateGameObjectWithHideFlags( name, HideFlags.HideInHierarchy, typeof(AssetBundleDataHolder) ); //プレハブにスクリプタブルオブジェクトを設置 UnityEngine.Object[] assets; string assetName = SystemSetting.GetAssetBundleDataFolder() + "AssetBundleDataAsset"; assets = Resources.LoadAll(assetName); Debug.LogWarning("GetObj :" + assetName.ToString()); AssetBundleData tmp = new AssetBundleData(); foreach (UnityEngine.Object asset in assets) { if (asset is AssetBundleData) { tmp = (AssetBundleData)asset; } } AssetBundleDataHolder holder = gameObject.GetComponent <AssetBundleDataHolder> (); holder.assetBundleData = tmp; SetScriptableData(typeof(AssetBundleData)); PrefabUtility.CreatePrefab(outputPath, gameObject, ReplacePrefabOptions.ReplaceNameBased); Editor.DestroyImmediate(gameObject); }