示例#1
0
        public static void LoadAsync(MonoBehaviour dependObject, string path, System.Type type, System.Action <Object> callback)
        {
            //  Debug.Log("LoadAsset Aysnc:" + path);
            if (!patchFiles.ContainsKey(path.ToLower()))
            {
                string fullPath = path.StartsWith("Assets/") ? path : ("Assets/" + ResourceBundle.RESOURCES_DIR + "/" + AddFileExtension(path));

                Statistics.AddAsset(fullPath);

#if UNITY_EDITOR
                if (AssetManager.SimulateMode)
                {
                    GetLoader().StartCoroutine(SimulateLoadThread(path, type, callback, dependObject));
                    return;
                }
#endif
                string ab = BundleInfoManager.GetBundleNameWithFullPath(fullPath);
                if (!string.IsNullOrEmpty(ab))
                {
                    AssetManager.LoadAsync(GetLoader(), fullPath, type, callback);
                    return;
                }
            }
            GetLoader().StartCoroutine(LoadThread(path, type, callback, dependObject));
        }
示例#2
0
        public static T Load <T>(string path) where T : Object
        {
            // Debug.Log("LoadAsset:" + path);
            path = AddFileExtension(path);
            string fullPath = "Assets/" + ResourceBundle.RESOURCES_DIR + "/" + path;

            Statistics.AddAsset(fullPath);

            Object    asset = null;
            PatchInfo info;

            if (patchFiles.TryGetValue(path.ToLower(), out info))
            {
                return(info.assetBundle.LoadAsset <T>(info.fullName));
            }
#if UNITY_EDITOR
            if (AssetManager.SimulateMode)
            {
                asset = AssetDatabase.LoadAssetAtPath <T>(fullPath);
                if (asset == null)
                {
                    asset = Resources.Load <T>(GetResourceName(path));
                }
                if (asset == null)
                {
                    Debug.LogErrorFormat("load error {0}", path);
                    return(null);
                }
                return(asset as T);
            }
#endif
            asset = AssetManager.Load <T>(fullPath);
            if (asset == null)
            {
                asset = Resources.Load <T>(GetResourceName(path));
            }
            if (asset == null)
            {
                Debug.LogErrorFormat("load error {0}", path);
                return(null);
            }

            return(asset as T);
        }