Example #1
0
 /// <summary>
 /// 读取一个资源,不需要加载依赖文件的使用该方法
 /// </summary>
 /// <param name="loadName"></param>
 /// <param name="suffixalName"></param>
 /// <param name="action"></param>
 public void GetObjWithParams(string loadName, string suffixalName, Action <AssetbundleParams> action)
 {
     StartCoroutine(AssetBundleHelper.LoadAssetObject("Devices", loadName, suffixalName, (obj) =>
     {
         if (action != null)
         {
             AssetbundleParams args = new AssetbundleParams();
             args.name = loadName;
             args.obj  = obj;
             action(args);
         }
     }));
 }
Example #2
0
    ///// <summary>
    ///// 读取一个资源,不需要加载依赖文件的使用该方法
    ///// </summary>
    //public IEnumerator GetObj(string loadName, string suffixalName, Action<UnityEngine.Object> action)
    //{
    //    yield return AssetBundleHelper.LoadAssetObject("Devices", loadName, suffixalName, action));
    //}

    /// <summary>
    /// 读取一个资源,不需要加载依赖文件的使用该方法
    /// </summary>
    public IEnumerator GetObjFromCatch(string loadName, string suffixalName, Action <UnityEngine.Object> action)
    {
        GameObject modelT = ModelIndex.Instance.Get(loadName);

        if (modelT != null)
        {
            if (action != null)
            {
                action(modelT);
            }
            //yield return null;
        }
        else
        {
            yield return(AssetBundleHelper.LoadAssetObject("Devices", loadName, suffixalName, action)); //内部也是LoadAssetObject
        }
    }
Example #3
0
    public static IEnumerator LoadCommonModels(List <string> models, bool showProgress)
    {
        for (int i = 0; i < models.Count; i++)
        {
            string model = models[i];
            if (string.IsNullOrEmpty(model))
            {
                continue;
            }
            GameObject modelT = ModelIndex.Instance.Get(model);
            if (modelT != null)
            {
                models.RemoveAt(i); i--;//这种删除i--不能忘记
            }
        }

        for (int i = 0; i < models.Count; i++)
        {
            if (showProgress)
            {
                float percent = (i + 1) / models.Count;
                ProgressbarLoad.Instance.Show(percent);//模型进度
            }
            string model = models[i];
            yield return(AssetBundleHelper.LoadAssetObject("Devices", model, AssetbundleGetSuffixalName.prefab, obj =>
            {
                if (obj == null)
                {
                    Debug.LogError("获取不到模型:" + model);
                }
                else
                {
                    GameObject g = obj as GameObject;
                    ModelIndex.Instance.Add(g, model); //添加到缓存中
                    Debug.LogError("Info:加载模型:" + model);
                }
            })); //携程方式读取模型文件
        }
    }
Example #4
0
 /// <summary>
 /// 读取一个资源,不需要加载依赖文件的使用该方法
 /// </summary>
 /// <param name="loadName"></param>
 /// <param name="suffixalName"></param>
 /// <param name="action"></param>
 public void GetObj(string loadName, string suffixalName, Action <UnityEngine.Object> action)
 {
     StartCoroutine(AssetBundleHelper.LoadAssetObject("Devices", loadName, suffixalName, action));
 }