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(); } }
private void OnLoadShdaerBytesComplete(string fileUri, byte[] bytes, string errorMessage) { if (bytes == null || bytes.Length <= 0) { string errormessage = TextUtil.Format("shdaer '{0}' is invalid, error message is '{1}'.", fileUri, string.IsNullOrEmpty(errorMessage) ? "<Empty>" : errorMessage); if (m_PreLoadShaderCallBack.PreLoadShaderFailure != null) { m_PreLoadShaderCallBack.PreLoadShaderFailure(errormessage); } throw new Exception(errormessage); } bytes = SecurityUtil.Xor(bytes); m_ResourceHelper.PreLoadShader(bytes, m_PreLoadShaderCallBack); }