Exemple #1
0
    IEnumerator LoadAsync(string path)
    {
        if (request != null)
        {
            ResMgr.Log(Tag, "LoadAsync", "this should never happen tooo !!");
        }
        if (!File.Exists(path))
        {
            ResMgr.Log(Tag, "LoadAsync", "async path is not exist");
            State = AbBundleState.error;
            yield break;
        }
        request = AssetBundle.LoadFromFileAsync(path);
        yield return(request);

        if (request.isDone)
        {
            this.Log("AbAsyncLoader LoadAsync succ==>" + path);
            Bundle = request.assetBundle;
            State  = AbBundleState.success;
            AbMgr.GetInstance().OnAbAsyncDownloadOver(m_Ab_Name.GetHashCode());
        }
        else
        {
            State = AbBundleState.error;
            this.Log("async big problem");
        }
    }
Exemple #2
0
 public bool Tick()
 {
     if (dynamicdepends.Count > 0)
     {
         for (int i = dynamicdepends.Count - 1; i > -1; i--)
         {
             if (AbMgr.GetInstance().isHaveAb(dynamicdepends[i]))
             {
                 dynamicdepends.RemoveAt(i);
             }
         }
         if (dynamicdepends.Count == 0 && request.isDone)
         {
             if (m_callback != null)
             {
                 m_callback(Bundle);
                 m_callback = null;
             }
             this.Log("depends is load over self callback");
             return(true);
         }
         return(false);
     }
     else
     {
         if (m_callback != null)
         {
             m_callback(Bundle);
             m_callback = null;
         }
         this.Log("depends count == 0");
         return(true);
     }
 }
Exemple #3
0
 public override void LoadAsset(string path)
 {
     depends = AbMgr.GetInstance().GetDepends(m_Ab_Name);
     dynamicdepends.Clear();
     dynamicdepends.AddRange(depends);
     AbMgr.GetInstance().StartCoroutine(LoadAsync(path));
 }
Exemple #4
0
    IEnumerator NextStep()
    {
        yield return(StartCoroutine(AbMgr.GetInstance().Init()));

        //UIMgr.ShowTips(UIPageEnum.Effect_Tips);
        UIMgr.GetInstance().ShowPage(UIPageEnum.Main_Page);
    }
Exemple #5
0
    private static T Load <T>(string path) where T : UnityEngine.Object
    {
        int    hash = path.GetHashCode();
        object obj;

#if UNITY_EDITOR
        if (AbMgr.IsAbMode)
        {
            //Debug.Log("max==>" + filepath);
            AssetBundle ab = AbMgr.GetInstance().SyncLoad(path);
            return(ab.LoadAsset <T>(ab.GetAllAssetNames()[0]));
        }
        else
        {
            //Debug.Log("max=111=>" + filepath);
            path = "Assets/" + XGamePath.ResRoot + "/" + path;
            //Debug.Log("max=22=>" + path);
            obj = UnityEditor.AssetDatabase.LoadAssetAtPath <T>(path);
            return(obj as T);
        }
#else
        Log(Tag, "Load", path);

        AssetBundle ab = AbMgr.GetInstance().SyncLoad(path);
        obj = ab.LoadAsset <T>(ab.GetAllAssetNames()[0]);
        return(obj as T);
#endif
    }
Exemple #6
0
    public override void Process()
    {
        //UI部分
        UIMgr.GetInstance().LoadUIAsync((int)UIPageEnum.LevelList_Page, () => { Callback(); });
        UIMgr.GetInstance().LoadUIAsync((int)UIPageEnum.Main_Page, () => { Callback(); });
        UIMgr.GetInstance().LoadUIAsync((int)UIPageEnum.Play_Page, () => { Callback(); });

        //shader
        AbMgr.GetInstance().AsyncLoad("shaders", null);
    }
Exemple #7
0
    // Start is called before the first frame update
    void Start()
    {
        abMgr = AbMgr.instance;
        dropdown.ClearOptions();
        if (abMgr.assetInfos != null)
        {
            foreach (var ai in abMgr.assetInfos)
            {
                dropdown.options.Add(new Dropdown.OptionData(ai.assetName + ai.type));
            }
        }

        dropdown.onValueChanged.AddListener(OnOptionChange);
    }
Exemple #8
0
    public static void LoadAsync <T>(string path, Action <T> callback) where T : UnityEngine.Object
    {
        int hash = path.GetHashCode();

#if UNITY_EDITOR
        if (AbMgr.IsAbMode)
        {
            //Debug.Log("max==>" + filepath);
            AssetBundle          ab;
            Action <AssetBundle> de = (a) =>
            {
                if (a == null)
                {
                    Log(Tag, "LoadAsync", "ab is emptty " + path);
                }
                ab = a;
                AssetBundleRequest abr = ab.LoadAssetAsync <T>(ab.GetAllAssetNames()[0]);
                if (abr == null)
                {
                    Log(Tag, "LoadAsync", "ab is emptty " + path + "|ab name = " + ab.GetAllAssetNames()[0]);
                    return;
                }
                AbMgr.GetInstance().StartCoroutine(LoadAssetAsync(abr, callback));
            };
            AbMgr.GetInstance().AsyncLoad(path, de);
        }
        else
        {
            object obj;
            path = "Assets/" + XGamePath.ResRoot + "/" + path;
            obj  = UnityEditor.AssetDatabase.LoadAssetAtPath <T>(path);
            callback(obj as T);
        }
#else
        Action <AssetBundle> de = (ab) =>
        {
            Debug.Log("LoadAsset==>" + ab.GetAllAssetNames()[0]);
            //T tobj = ab.LoadAsset<T>(ab.GetAllAssetNames()[0]);
            //callback(tobj);
            AssetBundleRequest abr = ab.LoadAssetAsync <T>(ab.GetAllAssetNames()[0]);
            AbMgr.GetInstance().StartCoroutine(LoadAssetAsync(abr, callback));
        };
        AbMgr.GetInstance().AsyncLoad(path, de);
#endif
    }
 public void Say(string ab, string call)
 {
     Debug.Log("I am test!!11111111111111 and b ==" + call);
     AbMgr.LoadAssetBundle(ab, call);
 }