예제 #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();
            }
        }