예제 #1
0
    public UnityEngine.Object GetAsset(string path)
    {
        UnityEngine.Object ret = null;
        if (mObs.TryGetValue(path, out ret))
        {
            return(ret);
        }
        if (null != mCurElems)
        {
            PatcherElem.Elem elem = null;
            if (mCurElems.mDic.TryGetValue(path, out elem))
            {
                if (elem.mDepends != null && elem.mDepends.Length > 0)
                {
                    foreach (var d in elem.mDepends)
                    {
                        GetAsset(d);
                    }
                }

                AssetBundle ab = AssetBundle.LoadFromFile(Application.persistentDataPath + "/" + path);
                if (null != ab)
                {
                    ret           = ab.LoadAsset(path);
                    mObs[path]    = ret;
                    mAssets[path] = ab;
                }
            }
        }
        return(ret);
    }
예제 #2
0
 bool IsDepenceLoaded(string path)
 {
     if (null != mCurElems)
     {
         PatcherElem.Elem elem = null;
         if (mCurElems.mDic.TryGetValue(path, out elem))
         {
             if (elem.mDepends != null && elem.mDepends.Length > 0)
             {
                 foreach (var d in elem.mDepends)
                 {
                     if (!mObs.ContainsKey(path))
                     {
                         return(false);
                     }
                 }
             }
             else
             {
                 return(true);
             }
         }
         return(true);
     }
     return(true);
 }
예제 #3
0
 public void LoadAssetAsyn(string path, System.Action <UnityEngine.Object> callback)
 {
     if (mObs.ContainsKey(path))
     {
         if (null != callback)
         {
             callback(mObs[path]);
         }
     }
     else
     {
         if (mReqs.ContainsKey(path))
         {
             if (null != callback)
             {
                 BundleRequest br = new BundleRequest();
                 br.mPath     = path;
                 br.mCallback = callback;
                 mBuff.Add(br);
             }
         }
         else
         {
             if (null != mCurElems)
             {
                 PatcherElem.Elem elem = null;
                 if (mCurElems.mDic.TryGetValue(path, out elem))
                 {
                     if (elem.mDepends != null && elem.mDepends.Length > 0)
                     {
                         foreach (var d in elem.mDepends)
                         {
                             LoadAssetAsyn(d, null);
                         }
                     }
                     AssetBundleCreateRequest ar = AssetBundle.LoadFromFileAsync(GetAssetPath(path));
                     mReqs[path] = ar;
                 }
             }
         }
     }
 }
예제 #4
0
        public bool IsChange(PatcherElem.Elem elem)
        {
            Elem me = null;

            mDic.TryGetValue(elem.szName, out me);
            if (me == null)
            {
                return(true);
            }
            else if (me.mVersion != elem.mVersion)
            {
                return(true);
            }
            else
            {
                string path = Application.persistentDataPath + "/" + elem.szName;
                if (!File.Exists(path))
                {
                    return(true);
                }
            }
            return(false);
        }