Example #1
0
    public static AssetBundleLoadManifestOperation Initialize(string manifestAssetBundleName)
    {
#if UNITY_EDITOR
        Debug.LogFormat("<color=green>Simulation Mode: {0}</color>", (SimulateAssetBundleInEditor ? "Enabled" : "Disabled"));
#endif

        GameObject go = GameObject.Find("/AssetBundleManager");
        if (go == null)
        {
            go = new GameObject("AssetBundleManager");
            DontDestroyOnLoad(go);
        }
        m_instance = go.AddMissingComponent <AssetBundleManager>();

#if UNITY_EDITOR
        if (SimulateAssetBundleInEditor)
        {
            return(null);
        }
#endif
        LoadManifest(manifestAssetBundleName);
        AssetBundleLoadManifestOperation operation = new AssetBundleLoadManifestOperation(manifestAssetBundleName, "AssetBundleManifest", typeof(AssetBundleManifest));
        m_InProgressOperations.Add(operation);
        return(operation);
    }
Example #2
0
    // Initialize the downloading url and AssetBundleManifest object.
    protected IEnumerator InitializeManifest()
    {
        // With this code, when in-editor or using a development builds: Always use the AssetBundle Server
        // (This is very dependent on the production workflow of the project.
        //  Another approach would be to make this configurable in the standalone player.)
#if DEVELOPMENT_BUILD || UNITY_EDITOR
        AssetBundleManager.SetDevelopmentAssetBundleServer();
#else
        // Use the following code if AssetBundles are embedded in the project for example via StreamingAssets folder etc:
        //AssetBundleManager.SetSourceAssetBundleURL(Application.streamingAssetsPath + "/");
        // Or customize the URL based on your deployment or configuration
        //AssetBundleManager.SetSourceAssetBundleURL("http://www.MyWebsite/MyAssetBundles");

        //AssetBundleManager.SetSourceAssetBundleURL("http://1.235.170.142/shared/AssetBundle");
        AssetBundleManager.SetSourceAssetBundleURL(Application.streamingAssetsPath + "/");
#endif

        // Initialize AssetBundleManifest which loads the AssetBundleManifest object.
        m_Request = AssetBundleManager.Initialize();
        if (m_Request != null)
        {
            yield return(StartCoroutine(m_Request));
        }

        m_Initialized = true;
    }
Example #3
0
	// Load AssetBundleManifest.
	public AssetBundleLoadManifestOperation Initialize (string manifestAssetBundleName)
	{
		LoadAssetBundle(manifestAssetBundleName, true);
		var operation = new AssetBundleLoadManifestOperation (manifestAssetBundleName, "AssetBundleManifest", typeof(AssetBundleManifest));
		m_InProgressOperations.Add (operation);
		return operation;
	}
Example #4
0
        public void Initialize(string localAssetBundlePath, string remoteAssetBundlePath, OnLoadComplete callback, AssetBundleManager.LoadMode loadMode = AssetBundleManager.LoadMode.Internal, AssetBundleManager.LogMode logMode = AssetBundleManager.LogMode.JustErrors)
        {
            if (!AssetBundleManager.IsInited)
            {
                //1.场景的加载/卸载管理
                SceneManager.sceneLoaded   += OnSceneLoaded;
                SceneManager.sceneUnloaded += OnSceneUnloaded;

                //bundle的加载/卸载管理
                AssetBundleManager.loadMode = loadMode;
                AssetBundleManager.logMode  = logMode;

                //设置本地资源加载路径,和远端资源加载路径
                AssetBundleManager.SetLocalAssetBundleDirectory(localAssetBundlePath);
                AssetBundleManager.SetRemoteAssetBundleURL(remoteAssetBundlePath);

                //todo 需要和热更逻辑配合
                // string file = Path.Combine(AssetBundleManager.BaseLocalURL, Utility.GetPlatformName());
                // if (File.Exists(file))
                // {
                //     File.Delete(file);
                // }

                AssetBundleManager.ActiveVariants = new string[] { "bundle" };

                RegistCallback(Utility.GetPlatformName(), callback); //资源初始化完成的回调
                m_AssetBundleLoadManifestOperation = AssetBundleManager.Initialize();
            }
            else
            {
                StartCoroutine(_YieldCallback(callback));
            }
        }
Example #5
0
 public void Initialize()
 {
     AssetBundles.AssetBundleManager.SetSourceAssetBundleDirectory(
         "/AssetBundles/" + Utility.GetPlatformName() + "/");
     loadOperation = AssetBundleManager.Initialize();
     tickableManager.AddLate(this);
 }
 static public int Update(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         AssetBundleLoadManifestOperation self = (AssetBundleLoadManifestOperation)checkSelf(l);
         var ret = self.Update();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Example #7
0
 static public AssetBundleLoadManifestOperation ReloadManifest(string manifestAssetBundleName)
 {
     UnloadAssetBundleInternal(manifestAssetBundleName);
     LoadAssetBundle(manifestAssetBundleName, true);
     var operation = new AssetBundleLoadManifestOperation(manifestAssetBundleName, "AssetBundleManifest", typeof(AssetBundleManifest));
     m_InProgressOperations.Add(operation);
     return operation;
 }
Example #8
0
    private static AssetBundleLoadManifestOperation InitializeAsync(string manifestAssetBundleName)
    {
        LoadAssetBundle(manifestAssetBundleName, 0, true);

        var operation = new AssetBundleLoadManifestOperation(manifestAssetBundleName, manifestAssetBundleName, typeof(AssetBundleManifest));

        inProgressOperationList.Add(operation);
        return(operation);
    }
    static AssetBundleLoadManifestOperation LoadManifestAsset()
    {
        //s_PlatformDir = “Windows”
        LoadAssetBundle(s_PlatformDir, true);
        AssetBundleLoadManifestOperation operation = new AssetBundleLoadManifestOperation(s_PlatformDir, "AssetBundleManifest", typeof(AssetBundleManifest));

        s_DownloadingOps.Add(operation);

        return(operation);
    }
    IEnumerator Start()
    {
        //获取资源包在硬件平台文件目录,存储在s_PlatformDir
        Init();
        //获取AssetBundles清单
        AssetBundleLoadManifestOperation op = LoadManifestAsset();

        //开始获取清单
        //使用 yield 关键字,则意味着它在其中出现的方法、运算符或 get 访问器是迭代器
        yield return(StartCoroutine(op));
    }
Example #11
0
    // Load AssetBundleManifest.
    static public AssetBundleLoadManifestOperation Initialize(string manifestAssetBundleName)
    {
        var go = new GameObject("AssetBundleManager", typeof(AssetBundleManager));

#if UNITY_EDITOR
        // If we're in Editor simulation mode, we don't need the manifest assetBundle.
        if (SimulateAssetBundleInEditor)
            return null;
#endif

        LoadAssetBundle(manifestAssetBundleName, true);
        var operation = new AssetBundleLoadManifestOperation(manifestAssetBundleName, "AssetBundleManifest", typeof(AssetBundleManifest));
        m_InProgressOperations.Add(operation);
        return operation;
    }
    // Load AssetBundleManifest.
    static public AssetBundleLoadManifestOperation Initialize(string manifestAssetBundleName)
    {
        var go = new GameObject("AssetBundleManager", typeof(AssetBundleManager));
        DontDestroyOnLoad(go);
        //ManagerManager.Instance.CLEAN_TARGET.Add(go);

#if UNITY_EDITOR
        // If we're in Editor simulation mode, we don't need the manifest assetBundle.
        if (SimulateAssetBundleInEditor)
            return null;
#endif
        strPlatformManifestName = manifestAssetBundleName;
        LoadAssetBundle(manifestAssetBundleName, true);
        var operation = new AssetBundleLoadManifestOperation(manifestAssetBundleName, "AssetBundleManifest", typeof(AssetBundleManifest));
        m_InProgressOperations.Add(operation);
        return operation;
    }
	// Load AssetBundleManifest.
	public AssetBundleLoadManifestOperation ABM_02_Initialize (string manifestAssetBundleName)
	{
		var go = new GameObject("AssetBundleManager", typeof(AssetBundleManager));
		DontDestroyOnLoad(go);
		Debug.Log ("---------ABM_02_Initialize  manifestAssetBundleName=" + manifestAssetBundleName + " go= "+go+ "----------------");
		/*
#if UNITY_EDITOR	
		// If we're in Editor simulation mode, we don't need the manifest assetBundle.
		if (ABM_00_SimulateAssetBundleInEditor)
		{	
			Debug.Log ("---------ABM_02_Initialize  ABM_00_SimulateAssetBundleInEditor=" + ABM_00_SimulateAssetBundleInEditor + ")----------------");
			return null;
		}
#endif
*/
		ABM_03_LoadAssetBundle(manifestAssetBundleName, true);
		var operation = new AssetBundleLoadManifestOperation (manifestAssetBundleName, "AssetBundleManifest", typeof(AssetBundleManifest));
		m_InProgressOperations.Add (operation);
		return operation;
		Debug.Log ("---------ABM_02_Initialize  operation=" + operation + ")----------------");
	}
    // Load AssetBundleManifest.
    public AssetBundleLoadManifestOperation Initialize(string a_manifestAssetBundleName)
    {
        if (IsInitialized())
        {
            return(null);
        }

#if UNITY_EDITOR
        // If we're in Editor simulation mode, we don't need the manifest assetBundle.
        if (SimulateAssetBundleInEditor)
        {
            return(null);
        }
#endif

        LoadAssetBundle(a_manifestAssetBundleName, true);
        var operation = new AssetBundleLoadManifestOperation(a_manifestAssetBundleName, "AssetBundleManifest", typeof(AssetBundleManifest));
        m_inProgressOperationsByName.Add(a_manifestAssetBundleName, operation);
        m_inProgressOperations.Add(new KeyValuePair <string, AssetBundleLoadOperation>(a_manifestAssetBundleName, operation));
        return(operation);
    }
        Dictionary <string, Texture2D> dicTexture2D; //Sprite转Texture集合
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="initOK"></param>
        internal override async Task Initialize()
        {
            if (IsInitialize)
            {
                return;
            }
            AssetBundleManager.logMode = AssetBundleManager.LogMode.JustErrors;
            AssetBundleManager.Initialize();
            dicSprites   = new Dictionary <string, Sprite>();
            dicTexture2D = new Dictionary <string, Texture2D>();
            //AssetBundleManager.BaseDownloadingURL = ResUtil.GetRelativePath();
            AssetBundleLoadManifestOperation request = AssetBundleManager.LoadManifest(AppSetting.MineGameName);

            if (request == null)
            {
                return;
            }
            await request;

            IsInitialize = true;
            CLog.Log("AssetbundleModule初始化完成");
        }
Example #16
0
    // Load AssetBundleManifest.
    static public AssetBundleLoadManifestOperation Initialize(string manifestAssetBundleName)
    {
#if UNITY_EDITOR
        Log(LogType.Info, "Simulation Mode: " + (SimulateAssetBundleInEditor ? "Enabled" : "Disabled"));
        Debug.Log("매니페스트 이름 : " + manifestAssetBundleName);
#endif

        var go = new GameObject("AssetBundleManager", typeof(AssetBundleManager));
        DontDestroyOnLoad(go);

#if UNITY_EDITOR
        // If we're in Editor simulation mode, we don't need the manifest assetBundle.
        if (SimulateAssetBundleInEditor)
        {
            return(null);
        }
#endif

        LoadAssetBundle(manifestAssetBundleName, true);
        var operation = new AssetBundleLoadManifestOperation(manifestAssetBundleName, "AssetBundleManifest", typeof(AssetBundleManifest));
        m_InProgressOperations.Add(operation);
        return(operation);
    }
 static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         AssetBundleLoadManifestOperation o;
         System.String a1;
         checkType(l, 2, out a1);
         System.String a2;
         checkType(l, 3, out a2);
         System.Type a3;
         checkType(l, 4, out a3);
         o = new AssetBundleLoadManifestOperation(a1, a2, a3);
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
        // Initializes asset bundle namager and starts download of manifest asset bundle.
        // Returns the manifest asset bundle downolad operation object.
        static public AssetBundleLoadManifestOperation Initialize(string manifestAssetBundleName)
        {
    #if UNITY_EDITOR
            Log(LogType.Info, "Simulation Mode: " + (SimulateAssetBundleInEditor ? "Enabled" : "Disabled"));
    #endif

            var go = new GameObject("AssetBundleManager", typeof(AssetBundleManager));
            DontDestroyOnLoad(go);

    #if UNITY_EDITOR
            // If we're in Editor simulation mode, we don't need the manifest assetBundle.
            if (SimulateAssetBundleInEditor)
                return null;
    #endif

            LoadAssetBundle(manifestAssetBundleName, true);
            var operation = new AssetBundleLoadManifestOperation(manifestAssetBundleName, "AssetBundleManifest", typeof(AssetBundleManifest));
            m_InProgressOperations.Add(operation);
            return operation;
        }
Example #19
0
        protected override void OnUpdate(float delta)
        {
            base.OnUpdate(delta);

            if (!IsInited)
            {
                // 等AssetBundleManifest初始化完成,再继续更新其他Operation
#if UNITY_EDITOR
                if (AssetBundleManager.SimulateAssetBundleInEditor)
                {
                    IsInited = true;
                    Callback(Utility.GetPlatformName());
                }
                else
                {
#endif
                if (m_AssetBundleLoadManifestOperation != null && m_AssetBundleLoadManifestOperation.IsDone())
                {
                    IsInited = true;
                    Callback(Utility.GetPlatformName(), m_AssetBundleLoadManifestOperation.GetAsset <AssetBundleManifest>(), m_AssetBundleLoadManifestOperation.Error);
                    m_AssetBundleLoadManifestOperation = null;
                }
#if UNITY_EDITOR
            }
#endif
            }
            else
            {
                //bundle
                UpdateLoadAssets();

                //场景
                if (m_LoadSceneOpration != null)
                {
                    IsLoadingScene       = true;
                    LoadingSceneProgress = m_LoadSceneOpration.Progress();

                    if (m_LoadSceneOpration.IsDone() && !string.IsNullOrEmpty(m_LoadSceneOpration.Error))
                    {
                        IsLoadingScene = false;
                        Callback(m_LoadSceneOpration.LevelName, null, m_LoadSceneOpration.Error);
                        m_LoadSceneOpration = null;
                    }
                }
            }

#if UNITY_EDITOR
            if (isDirty)
            {
                isDirty = false;
                InspectorShower.Clear();
                InspectorShower.AddRange(m_AssetCaches.Values);
                InspectorShower.Sort(
                    (a, b) =>
                {
                    if (a.hold != b.hold)
                    {
                        return(a.hold - b.hold);
                    }
                    else if (a.refCount != b.refCount)
                    {
                        return(b.refCount - a.refCount);
                    }
                    else
                    {
                        return(string.Compare(a.assetName, b.assetName));
                    }
                });
            }
#endif
        }
    static AssetBundleLoadManifestOperation LoadManifestAsset()
    {
        //s_PlatformDir = “Windows”
        LoadAssetBundle(s_PlatformDir, true);
        AssetBundleLoadManifestOperation operation = new AssetBundleLoadManifestOperation(s_PlatformDir, "AssetBundleManifest", typeof(AssetBundleManifest));
        s_DownloadingOps.Add(operation);

        return operation;
    }
Example #21
0
        // Load AssetBundleManifest.
        /// <summary>
        /// 初始化操作,异步加载资源依赖总览
        /// </summary>
        /// <param name="manifestAssetBundleName">平台名</param>
        /// <returns></returns>
        static public AssetBundleLoadManifestOperation Initialize(string manifestAssetBundleName)
        {
#if UNITY_EDITOR
            Log(LogType.Info, "Simulation Mode: " + (SimulateAssetBundleInEditor ? "Enabled" : "Disabled"));
#endif

            // 创建资源管理对象的U3D GameObject 设置为不自动销毁
            var go = new GameObject("AssetBundleManager", typeof(AssetBundleManager));
            DontDestroyOnLoad(go);

#if UNITY_EDITOR
            // If we're in Editor simulation mode, we don't need the manifest assetBundle.
            // 如果是编辑器模式,且处于模式模式,不需要加载资源依赖总览
            if (SimulateAssetBundleInEditor)
                return null;
#endif

            // 下载资源,以及其依赖信息
            LoadAssetBundle(manifestAssetBundleName, true);
            // 创建异步加载请求,并放入准备处理队列
            var operation = new AssetBundleLoadManifestOperation(manifestAssetBundleName, "AssetBundleManifest",
                typeof(AssetBundleManifest));
            m_InProgressOperations.Add(operation);

            return operation;
        }
Example #22
0
        private IEnumerator StartUpMgrs()
        {
            // start up StateMgr
            yield return(YieldFactory.GetWaitForEndOfFrame());

            GStateManager.Instance.ForceStateInfo(_stateInfo);

            // warmup shaders inside /Resources/Shaders/ (do this once)
            Shader.WarmupAllShaders();

            // ensure the rest are setup
            yield return(YieldFactory.GetWaitForEndOfFrame());

            GCore.Instance.EnsureMgrsAreSetup();

            while (!GCore.Instance.IsInitialized)
            {
                yield return(YieldFactory.GetWaitForEndOfFrame());
            }

            // play music
            //GSoundMgr.Instance.PlayMusic("commonMusic");

#if ENABLE_ASSET_BUNDLES
#if SMRJ_HACK
            AssetBundleManager.SetDevelopmentAssetBundleServer();
#else
            // LIVE URL
            if (GCore.Wrapper.Client.AppId == "30015")
            {
                AssetBundleManager.SetSourceAssetBundleURL(ASSET_BUNDLE_URL_LIVE);
            }
            // TEST URL
            else
            {
                AssetBundleManager.SetSourceAssetBundleURL(ASSET_BUNDLE_URL);
            }
#endif

#if UNITY_EDITOR
            if (!AssetBundleManager.SimulateAssetBundleInEditor)
#endif
            {
                AssetBundleLoadManifestOperation request = AssetBundles.AssetBundleManager.Initialize();
                if (request != null)
                {
                    yield return(StartCoroutine(request));
                }

                while (AssetBundleManager.AssetBundleManifestObject == null)
                {
                    yield return(YieldFactory.GetWaitForEndOfFrame());
                }
            }

            AssetBundleManager.LoadAssetBundle("eggiesslotstate");
            while (AssetBundleManager.IsDownloadingBundles())
            {
                GStateManager.Instance.ForcedUpdatedLoadingAssetBundle();
                yield return(YieldFactory.GetWaitForEndOfFrame());
            }
            GStateManager.Instance.EnableLoadingScreen(false);
#endif

            yield return(StartCoroutine(loadCommonSounds()));

            yield return(YieldFactory.GetWaitForEndOfFrame());
        }
    // Load AssetBundleManifest.
    public static AssetBundleLoadManifestOperation StartLoading(string manifestAssetBundleName)
    {
        if (_instance == null){
            var go = new GameObject("AssetBundleManager", typeof(AssetBundleManager));
            _instance = go.GetComponent<AssetBundleManager>();
            DontDestroyOnLoad(go);
        }

        #if UNITY_EDITOR
        // If we're in Editor simulation mode, we don't need the manifest assetBundle.
        if (SimulateAssetBundleInEditor)
            return null;
        #endif

        Debuger.Log("StartLoading " + manifestAssetBundleName);
        LoadAssetBundle(manifestAssetBundleName, true);
        var operation = new AssetBundleLoadManifestOperation (manifestAssetBundleName, "AssetBundleManifest", typeof(AssetBundleManifest));
        m_InProgressOperations.Add (operation);
        return operation;
    }