65 lines
1.9 KiB
C#
65 lines
1.9 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.IO;
|
|||
|
using System.Text;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace Thousandto.Core.Base
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// WWW的工厂
|
|||
|
/// </summary>
|
|||
|
public class WWWFactory
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 获取某个文件的Cache的WWW对象
|
|||
|
/// </summary>
|
|||
|
/// <param name="filePath"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static WWW GetWWWFileCache(string filePath, bool inAndroidPkg)
|
|||
|
{
|
|||
|
WWW retval = null;
|
|||
|
string path = filePath;
|
|||
|
var code = AssetsCacheManager.GetFileVersion(filePath);
|
|||
|
if (!inAndroidPkg && !File.Exists(filePath))
|
|||
|
{
|
|||
|
Debug.LogError(string.Format(
|
|||
|
"AsyncLoadBundle load failed! NOT EXIST File:{0}",
|
|||
|
filePath));
|
|||
|
return retval;
|
|||
|
}
|
|||
|
|
|||
|
if (!inAndroidPkg)
|
|||
|
path = "file://" + filePath;
|
|||
|
//Debug.Log("WWWURL:"+filePath+";;code:"+code);
|
|||
|
retval = WWW.LoadFromCacheOrDownload(path, code);
|
|||
|
return retval;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取文件的WWW对象
|
|||
|
/// </summary>
|
|||
|
/// <param name="filePath"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static WWW GetWWWFile(string filePath ,bool inAndroidPkg)
|
|||
|
{
|
|||
|
WWW retval = null;
|
|||
|
var path = filePath;
|
|||
|
|
|||
|
if (!inAndroidPkg && !File.Exists(filePath))
|
|||
|
{
|
|||
|
Debug.LogError(string.Format(
|
|||
|
"AsyncLoadBundle load failed! NOT EXIST File:{0}",
|
|||
|
filePath));
|
|||
|
return retval;
|
|||
|
}
|
|||
|
if (!inAndroidPkg)
|
|||
|
path = "file://" + filePath;
|
|||
|
//Debug.Log("WWWURL:" + filePath);
|
|||
|
retval = new WWW(path);
|
|||
|
return retval;
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|