Хотелось бы поинтересоваться, если кто-то сталкивался с подобным вопросом "Как загруженный из AssetsBudle обьект по URL- ccылке, в дальнейшем загружать из кэша?", то есть мы один раз его загрузили, сохранили в кэш и при последующей загрузке мы могли вытащить обьект из кэша, а не при каждом старте приложения загружать по новой . Подскажите, помогите если кому то известен метод.
Вот собснно мой соурс код:
Синтаксис:
Используется csharp
public class LoadAssetsBundle : MonoBehaviour
{
public static LoadAssetsBundle manage;
AssetBundle assetBundle;
WWW www;
public string SceneNameToLoadAB;
bool loadingStart = false;
[SerializeField] Transform parentForAB;
/// <summary>
/// 11FFSZQ5BY9Vg6x67kkLlOm9275vfB3Jw
/// </summary>
[SerializeField] string url = "https://drive.google.com/uc?export=download&id=1xVWP64yAxmdg_SDxTDn_Qa9IV9A5Koxr";
[SerializeField] string url_city_online = "https://drive.google.com/uc?export=download&id=1JPvF5A9Ipel98rKU0_ZOfeKAzpL6bCNh";
[Header("Other")]
public GameObject loadingPanel;
public Image bg_fill;
public Text percent;
[Header("Loaded Object")]
[SerializeField] GameObject obj;
private void Awake()
{
if (manage == null)
{
manage = this;
}
}
public void loadCar8()
{
www = new WWW(url);
loadingPanel.SetActive(true);
loadingStart = true;
StartCoroutine(car(www));
}
// Update is called once per frame
private void Update()
{
if (loadingStart)
{
double v = http://www.progress;
bg_fill.fillAmount = (float)v;
v = System.Math.Round(v, 2);
v *= 100;
percent.text = "" + v + "%";
print("loadingStart");
}
}
IEnumerator car(WWW www)
{
yield return www;
while (http://www.isDone == false)
{
yield return null;
}
AssetBundle bundle = http://www.assetBundle;
if (http://www.error == null)
{
obj = (GameObject)bundle.LoadAsset("car11");
obj.GetComponentInChildren<Rigidbody>().isKinematic = true;
obj.transform.position = new Vector3(0,1.3f,0);
obj.transform.eulerAngles = new Vector2(0,0);
Instantiate(obj).transform.SetParent(parentForAB);
loadingPanel.SetActive(false);
loadingStart = false;
PlayerPrefs.SetInt("CarLoaded", 1);
print("Assets loading is completed");
}
else
{
Debug.Log(http://www.error);
}
}
{
public static LoadAssetsBundle manage;
AssetBundle assetBundle;
WWW www;
public string SceneNameToLoadAB;
bool loadingStart = false;
[SerializeField] Transform parentForAB;
/// <summary>
/// 11FFSZQ5BY9Vg6x67kkLlOm9275vfB3Jw
/// </summary>
[SerializeField] string url = "https://drive.google.com/uc?export=download&id=1xVWP64yAxmdg_SDxTDn_Qa9IV9A5Koxr";
[SerializeField] string url_city_online = "https://drive.google.com/uc?export=download&id=1JPvF5A9Ipel98rKU0_ZOfeKAzpL6bCNh";
[Header("Other")]
public GameObject loadingPanel;
public Image bg_fill;
public Text percent;
[Header("Loaded Object")]
[SerializeField] GameObject obj;
private void Awake()
{
if (manage == null)
{
manage = this;
}
}
public void loadCar8()
{
www = new WWW(url);
loadingPanel.SetActive(true);
loadingStart = true;
StartCoroutine(car(www));
}
// Update is called once per frame
private void Update()
{
if (loadingStart)
{
double v = http://www.progress;
bg_fill.fillAmount = (float)v;
v = System.Math.Round(v, 2);
v *= 100;
percent.text = "" + v + "%";
print("loadingStart");
}
}
IEnumerator car(WWW www)
{
yield return www;
while (http://www.isDone == false)
{
yield return null;
}
AssetBundle bundle = http://www.assetBundle;
if (http://www.error == null)
{
obj = (GameObject)bundle.LoadAsset("car11");
obj.GetComponentInChildren<Rigidbody>().isKinematic = true;
obj.transform.position = new Vector3(0,1.3f,0);
obj.transform.eulerAngles = new Vector2(0,0);
Instantiate(obj).transform.SetParent(parentForAB);
loadingPanel.SetActive(false);
loadingStart = false;
PlayerPrefs.SetInt("CarLoaded", 1);
print("Assets loading is completed");
}
else
{
Debug.Log(http://www.error);
}
}