Example #1
0
        private IEnumerator LoadShaderCoroutine(byte[] bytes, PreLoadShaderCallBack preLoadShaderCallBack)
        {
            AssetBundleCreateRequest BytesAssetBundleCreateRequest = AssetBundle.LoadFromMemoryAsync(bytes);

            yield return(BytesAssetBundleCreateRequest);

            AssetBundle assetBundle = BytesAssetBundleCreateRequest.assetBundle;

            try
            {
                m_Allshader = assetBundle.LoadAllAssets <Shader>();
                Debug.Log(m_Allshader.Length);
            }
            catch (Exception errorMessage)
            {
                if (preLoadShaderCallBack.PreLoadShaderFailure != null)
                {
                    preLoadShaderCallBack.PreLoadShaderFailure(errorMessage.ToString());
                }
                yield break;
            }
            Shader.WarmupAllShaders();
            assetBundle.Unload(false);
            if (preLoadShaderCallBack.PreLoadShaderSuccess != null)
            {
                preLoadShaderCallBack.PreLoadShaderSuccess();
            }
        }
Example #2
0
        /// <summary>
        /// 预加载Shader
        /// </summary>
        /// <param name="preLoadShaderCallBack">预加载shader回调函数集</param>
        public void PreLoadShader(PreLoadShaderCallBack preLoadShaderCallBack)
        {
            if (m_ResourceHelper == null)
            {
                throw new Exception("Please set resourceHelper first!");
            }

            m_PreLoadShaderCallBack = preLoadShaderCallBack;
            ResourceInfo resourceInfo = GameEntry.Resource.GetResourceInfo("shader");

            m_ResourceHelper.LoadBytes(PathUtil.GetRemotePath(resourceInfo.StorageInReadOnly ? GameEntry.Resource.ReadOnlyPath : GameEntry.Resource.ReadWritePath, PathUtil.GetResourceNameWithSuffix(resourceInfo.ResourceName)), OnLoadShdaerBytesComplete);
        }
Example #3
0
 /// <summary>
 /// 预加载Shader
 /// </summary>
 /// <param name="bytes">数据流</param>
 /// <param name="preLoadShaderCallBack">预加载Shader回调</param>
 public void PreLoadShader(byte[] bytes, PreLoadShaderCallBack preLoadShaderCallBack)
 {
     StartCoroutine(LoadShaderCoroutine(bytes, preLoadShaderCallBack));
 }
Example #4
0
 /// <summary>
 /// 预加载Shader
 /// </summary>
 /// <param name="preLoadShaderCallBack">预加载shader回调函数集</param>
 public void PreLoadShader(PreLoadShaderCallBack preLoadShaderCallBack)
 {
     m_ResourceManager.PreLoadShader(preLoadShaderCallBack);
 }