Пример #1
0
        public static AssetScene Create(string name)
        {
            if (string.IsNullOrEmpty(name))//空场景
            {
                GameObject obj = new GameObject("AssetScene");
                if (Application.isPlaying)
                {
                    GameObject.DontDestroyOnLoad(obj);
                }
                return(obj.AddComponent <AssetScene>());
            }
            else
            {
                GameObject obj = new GameObject("AssetScene");//需要加载资源
                if (Application.isPlaying)
                {
                    GameObject.DontDestroyOnLoad(obj);
                }
                AssetScene assetScene = obj.AddComponent <AssetScene>();

                assetScene.assetBundleName = GetAssetBundleNameOfScene(name);

                Debug.Log("Load scene from AB " + assetScene.assetBundleName);
                ABsManager.Load(assetScene.assetBundleName);

                return(assetScene);
            }
        }
Пример #2
0
        public Object LoadAsset(string path)
        {
            Object obj = null;

            path = string.Format(basePath, path.Replace("\\", "/"));
            string assetBundleName = AssetBundleAssetRecord.GetAssetBundleName(path);

            if (!string.IsNullOrEmpty(assetBundleName))
            {
                string assetName = string.Format("{0}", AssetBundleAssetRecord.GetAssetName(path));
                ABsManager.Load(assetBundleName);
                obj = ABsManager.Instance.loadedAssetBundles[assetBundleName].GetRes(assetName);
            }


            return(obj);
        }