- Home /
Question by
umatrix · Feb 04, 2021 at 01:29 PM ·
materialrenderqueue
crash when material access renderQueue property
I reset renderer shader after loading mesh from assetbundle. while Unity editor will crash when material access renderQueue property. Unity version 2020.1.6f1
public static void ResetSharedShader(GameObject go)
{
if (go == null) return;
try
{
Renderer[] renders = go.GetComponentsInChildren();
for (int i = 0, length = renders.Length; i < length; i++)
{
Material mat = renders[i].sharedMaterial;
Shader localShader;
if (mat != null)
{
string shaderName = mat.shader.name;
**int renderQueue = mat.renderQueue; //here**
localShader = Shader.Find(shaderName);
if (localShader != null)
{
mat.shader = localShader;
mat.renderQueue = renderQueue;
}
}
Material[] mats = renders[i].sharedMaterials;
for (int j = 0; j < mats.Length; j++)
{
if (mats[j] == null) continue;
localShader = Shader.Find(mats[j].shader.name);
int matRenderQueue = mats[j].renderQueue;
if (localShader != null)
{
mats[j].shader = localShader;
mats[j].renderQueue = matRenderQueue;
}
}
}
}
catch(Exception e)
{
UDebug.LogError(e.ToString());
}
}
and the crash report:
Stack Trace of Crashed Thread 110136:
0x00007FF6A186558F (Unity) Material::GetActualRenderQueue
0x00007FF6A1FDCDCC (Unity) Material_Get_Custom_PropRenderQueue
0x0000019E9030F070 (UnityEngine.CoreModule) UnityEngine.Material.get_renderQueue()
0x0000019E47A271DB (UBase) UBase.UObjectTool.ResetSharedShader()
0x0000019E47A26103 (Assembly-CSharp) AssetbundleManager.DealLoadRequest()
0x0000019E47A25CA3 (Assembly-CSharp) AssetbundleManager.OnFinishLoad()
0x0000019E47999B0B (Assembly-CSharp) <OnLoadAssetBundle>d__19.MoveNext()
0x0000019E479987CC (UnityEngine.CoreModule) UnityEngine.SetupCoroutine.InvokeMoveNext()
0x0000019E479988F7 (UnityEngine.CoreModule) <Module>.runtime_invoke_void_object_intptr()
0x00007FF8BE93D8C0 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke
0x00007FF8BE8C2912 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2921] do_runtime_invoke
0x00007FF8BE8CB96F (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2968] mono_runtime_invoke
0x00007FF6A1DCFD44 (Unity) scripting_method_invoke
0x00007FF6A1DC986B (Unity) ScriptingInvocation::Invoke
0x00007FF6A1D8AC90 (Unity) Coroutine::Run
0x00007FF6A1D8829C (Unity) Coroutine::ContinueCoroutine
0x00007FF6A174112B (Unity) AsyncOperation::InvokeCoroutine
0x00007FF6A257CDEC (Unity) UnityWebRequestAsyncOperation::InvokeCoroutine
0x00007FF6A257CFC9 (Unity) UnityWebRequestProto<UnityWebRequestTransport,AtomicRefCounter,RedirectHelper,ResponseHelper,DownloadHandler,UploadHandler,CertificateHandler,HeaderHelper,AsyncOperation>::Job_InvokeCoroutine
0x00007FF6A162076A (Unity) BackgroundJobQueue::ExecuteMainThreadJobs
0x00007FF6A14B661C (Unity) Texture::VerifyFileTextureUploadCompletion
0x00007FF6A13F21E3 (Unity) Texture2D::VerifyFileTextureUploadCompletion
0x00007FF6A13E052F (Unity) Texture2D::AwakeFromLoad
0x00007FF6A1EC3C47 (Unity) AwakeFromLoadQueue::InvokePersistentManagerAwake
0x00007FF6A1EC479E (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad
0x00007FF6A1EC482A (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad
0x00007FF6A1E5D165 (Unity) PersistentManager::IntegrateAllThreadedObjects
0x00007FF6A1E5D8A0 (Unity) PersistentManager::LoadAndIntegrateAllPreallocatedObjects
0x00007FF6A1E5E624 (Unity) PersistentManager::LoadObjects
0x00007FF6A0B0F514 (Unity) ProcessAssetBundleEntries
0x00007FF6A0B0E38D (Unity) LoadNamedObjectFromAssetBundle
0x00007FF6A0AFCA60 (Unity) AssetBundle::LoadAsset_Internal
0x00007FF6A0D73BDA (Unity) AssetBundle_CUSTOM_LoadAsset_Internal
0x0000019E4C2408DC (UnityEngine.AssetBundleModule) UnityEngine.AssetBundle.LoadAsset_Internal()
0x0000019E4C240743 (UnityEngine.AssetBundleModule) UnityEngine.AssetBundle.LoadAsset()
0x0000019E47A2705B (UnityEngine.AssetBundleModule) UnityEngine.AssetBundle.LoadAsset()
0x0000019E47A260A3 (Assembly-CSharp) AssetbundleManager.DealLoadRequest()
0x0000019E47A25CA3 (Assembly-CSharp) AssetbundleManager.OnFinishLoad()
0x0000019E47999B0B (Assembly-CSharp) <OnLoadAssetBundle>d__19.MoveNext()
0x0000019E479987CC (UnityEngine.CoreModule) UnityEngine.SetupCoroutine.InvokeMoveNext()
0x0000019E479988F7 (UnityEngine.CoreModule) <Module>.runtime_invoke_void_object_intptr()
0x00007FF8BE93D8C0 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke
0x00007FF8BE8C2912 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2921] do_runtime_invoke
0x00007FF8BE8CB96F (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2968] mono_runtime_invoke
0x00007FF6A1DCFD44 (Unity) scripting_method_invoke
0x00007FF6A1DC986B (Unity) ScriptingInvocation::Invoke
0x00007FF6A1D8AC90 (Unity) Coroutine::Run
0x00007FF6A1D8829C (Unity) Coroutine::ContinueCoroutine
0x00007FF6A174112B (Unity) AsyncOperation::InvokeCoroutine
0x00007FF6A257CDEC (Unity) UnityWebRequestAsyncOperation::InvokeCoroutine
0x00007FF6A257CFC9 (Unity) UnityWebRequestProto<UnityWebRequestTransport,AtomicRefCounter,RedirectHelper,ResponseHelper,DownloadHandler,UploadHandler,CertificateHandler,HeaderHelper,AsyncOperation>::Job_InvokeCoroutine
0x00007FF6A162076A (Unity) BackgroundJobQueue::ExecuteMainThreadJobs
0x00007FF6A14B661C (Unity) Texture::VerifyFileTextureUploadCompletion
0x00007FF6A13F21E3 (Unity) Texture2D::VerifyFileTextureUploadCompletion
0x00007FF6A13E052F (Unity) Texture2D::AwakeFromLoad
0x00007FF6A1EC3C47 (Unity) AwakeFromLoadQueue::InvokePersistentManagerAwake
0x00007FF6A1EC479E (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad
0x00007FF6A1EC482A (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad
0x00007FF6A1E5D165 (Unity) PersistentManager::IntegrateAllThreadedObjects
0x00007FF6A1E5D8A0 (Unity) PersistentManager::LoadAndIntegrateAllPreallocatedObjects
0x00007FF6A1E5E624 (Unity) PersistentManager::LoadObjects
0x00007FF6A0B0F514 (Unity) ProcessAssetBundleEntries
0x00007FF6A0B0E38D (Unity) LoadNamedObjectFromAssetBundle
0x00007FF6A0AFCA60 (Unity) AssetBundle::LoadAsset_Internal
0x00007FF6A0D73BDA (Unity) AssetBundle_CUSTOM_LoadAsset_Internal
0x0000019E4C2408DC (UnityEngine.AssetBundleModule) UnityEngine.AssetBundle.LoadAsset_Internal()
0x0000019E4C240743 (UnityEngine.AssetBundleModule) UnityEngine.AssetBundle.LoadAsset()
0x0000019E47A2705B (UnityEngine.AssetBundleModule) UnityEngine.AssetBundle.LoadAsset()
0x0000019E47A260A3 (Assembly-CSharp) AssetbundleManager.DealLoadRequest()
0x0000019E47A25CA3 (Assembly-CSharp) AssetbundleManager.OnFinishLoad()
0x0000019E47999A43 (Assembly-CSharp) <OnLoadAssetBundle>d__19.MoveNext()
0x0000019E479987CC (UnityEngine.CoreModule) UnityEngine.SetupCoroutine.InvokeMoveNext()
0x0000019E479988F7 (UnityEngine.CoreModule) <Module>.runtime_invoke_void_object_intptr()
0x00007FF8BE93D8C0 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke
0x00007FF8BE8C2912 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2921] do_runtime_invoke
0x00007FF8BE8CB96F (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2968] mono_runtime_invoke
0x00007FF6A1DCFD44 (Unity) scripting_method_invoke
0x00007FF6A1DC986B (Unity) ScriptingInvocation::Invoke
0x00007FF6A1D8AC90 (Unity) Coroutine::Run
0x00007FF6A1D8829C (Unity) Coroutine::ContinueCoroutine
0x00007FF6A174112B (Unity) AsyncOperation::InvokeCoroutine
0x00007FF6A257CDEC (Unity) UnityWebRequestAsyncOperation::InvokeCoroutine
0x00007FF6A257CFC9 (Unity) UnityWebRequestProto<UnityWebRequestTransport,AtomicRefCounter,RedirectHelper,ResponseHelper,DownloadHandler,UploadHandler,CertificateHandler,HeaderHelper,AsyncOperation>::Job_InvokeCoroutine
0x00007FF6A162076A (Unity) BackgroundJobQueue::ExecuteMainThreadJobs
0x00007FF6A14B661C (Unity) Texture::VerifyFileTextureUploadCompletion
0x00007FF6A13F21E3 (Unity) Texture2D::VerifyFileTextureUploadCompletion
0x00007FF6A13E052F (Unity) Texture2D::AwakeFromLoad
0x00007FF6A1EC3C47 (Unity) AwakeFromLoadQueue::InvokePersistentManagerAwake
0x00007FF6A1EC479E (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad
0x00007FF6A1EC482A (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad
0x00007FF6A1E5D165 (Unity) PersistentManager::IntegrateAllThreadedObjects
0x00007FF6A1E5D8A0 (Unity) PersistentManager::LoadAndIntegrateAllPreallocatedObjects
0x00007FF6A1E60BC2 (Unity) PersistentManager::ReadObject
0x00007FF6A099C6B5 (Unity) PPtr<Texture2D>::operator Texture2D * __ptr64
0x00007FF6A155EABF (Unity) SpriteRenderer::SetupProperties
0x00007FF6A155873E (Unity) SpriteRenderer::AwakeFromLoad
0x00007FF6A1EC3C47 (Unity) AwakeFromLoadQueue::InvokePersistentManagerAwake
0x00007FF6A1EC479E (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad
0x00007FF6A1EC482A (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad
0x00007FF6A1E5D165 (Unity) PersistentManager::IntegrateAllThreadedObjects
0x00007FF6A1E5D8A0 (Unity) PersistentManager::LoadAndIntegrateAllPreallocatedObjects
0x00007FF6A1E5E624 (Unity) PersistentManager::LoadObjects
0x00007FF6A0B0F4C5 (Unity) ProcessAssetBundleEntries
0x00007FF6A0B0E38D (Unity) LoadNamedObjectFromAssetBundle
0x00007FF6A0AFCA60 (Unity) AssetBundle::LoadAsset_Internal
0x00007FF6A0D73BDA (Unity) AssetBundle_CUSTOM_LoadAsset_Internal
0x0000019E4C2408DC (UnityEngine.AssetBundleModule) UnityEngine.AssetBundle.LoadAsset_Internal()
0x0000019E4C240743 (UnityEngine.AssetBundleModule) UnityEngine.AssetBundle.LoadAsset()
0x0000019E47A2705B (UnityEngine.AssetBundleModule) UnityEngine.AssetBundle.LoadAsset()
0x0000019E47A260A3 (Assembly-CSharp) AssetbundleManager.DealLoadRequest()
0x0000019E47A25CA3 (Assembly-CSharp) AssetbundleManager.OnFinishLoad()
0x0000019E47999A43 (Assembly-CSharp) <OnLoadAssetBundle>d__19.MoveNext()
0x0000019E479987CC (UnityEngine.CoreModule) UnityEngine.SetupCoroutine.InvokeMoveNext()
0x0000019E479988F7 (UnityEngine.CoreModule) <Module>.runtime_invoke_void_object_intptr()
0x00007FF8BE93D8C0 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke
0x00007FF8BE8C2912 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2921] do_runtime_invoke
0x00007FF8BE8CB96F (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2968] mono_runtime_invoke
0x00007FF6A1DCFD44 (Unity) scripting_method_invoke
0x00007FF6A1DC986B (Unity) ScriptingInvocation::Invoke
0x00007FF6A1D8AC90 (Unity) Coroutine::Run
0x00007FF6A1D8829C (Unity) Coroutine::ContinueCoroutine
0x00007FF6A174112B (Unity) AsyncOperation::InvokeCoroutine
0x00007FF6A257CDEC (Unity) UnityWebRequestAsyncOperation::InvokeCoroutine
0x00007FF6A257CFC9 (Unity) UnityWebRequestProto<UnityWebRequestTransport,AtomicRefCounter,RedirectHelper,ResponseHelper,DownloadHandler,UploadHandler,CertificateHandler,HeaderHelper,AsyncOperation>::Job_InvokeCoroutine
0x00007FF6A162076A (Unity) BackgroundJobQueue::ExecuteMainThreadJobs
0x00007FF6A14B661C (Unity) Texture::VerifyFileTextureUploadCompletion
0x00007FF6A13F21E3 (Unity) Texture2D::VerifyFileTextureUploadCompletion
0x00007FF6A13E052F (Unity) Texture2D::AwakeFromLoad
0x00007FF6A1EC3C47 (Unity) AwakeFromLoadQueue::InvokePersistentManagerAwake
0x00007FF6A1EC479E (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad
0x00007FF6A1EC482A (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad
0x00007FF6A1E5D165 (Unity) PersistentManager::IntegrateAllThreadedObjects
0x00007FF6A1E5D8A0 (Unity) PersistentManager::LoadAndIntegrateAllPreallocatedObjects
0x00007FF6A1E5E624 (Unity) PersistentManager::LoadObjects
0x00007FF6A0B0F514 (Unity) ProcessAssetBundleEntries
0x00007FF6A0B0E38D (Unity) LoadNamedObjectFromAssetBundle
0x00007FF6A0AFCA60 (Unity) AssetBundle::LoadAsset_Internal
0x00007FF6A0D73BDA (Unity) AssetBundle_CUSTOM_LoadAsset_Internal
0x0000019E4C2408DC (UnityEngine.AssetBundleModule) UnityEngine.AssetBundle.LoadAsset_Internal()
0x0000019E4C240743 (UnityEngine.AssetBundleModule) UnityEngine.AssetBundle.LoadAsset()
0x0000019E47A2705B (UnityEngine.AssetBundleModule) UnityEngine.AssetBundle.LoadAsset()
0x0000019E47A260A3 (Assembly-CSharp) AssetbundleManager.DealLoadRequest()
0x0000019E47A25CA3 (Assembly-CSharp) AssetbundleManager.OnFinishLoad()
0x0000019E47999B0B (Assembly-CSharp) <OnLoadAssetBundle>d__19.MoveNext()
0x0000019E479987CC (UnityEngine.CoreModule) UnityEngine.SetupCoroutine.InvokeMoveNext()
0x0000019E479988F7 (UnityEngine.CoreModule) <Module>.runtime_invoke_void_object_intptr()
0x00007FF8BE93D8C0 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke
0x00007FF8BE8C2912 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2921] do_runtime_invoke
0x00007FF8BE8CB96F (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2968] mono_runtime_invoke
0x00007FF6A1DCFD44 (Unity) scripting_method_invoke
0x00007FF6A1DC986B (Unity) ScriptingInvocation::Invoke
0x00007FF6A1D8AC90 (Unity) Coroutine::Run
0x00007FF6A1D8829C (Unity) Coroutine::ContinueCoroutine
0x00007FF6A174112B (Unity) AsyncOperation::InvokeCoroutine
0x00007FF6A257CDEC (Unity) UnityWebRequestAsyncOperation::InvokeCoroutine
0x00007FF6A257CFC9 (Unity) UnityWebRequestProto<UnityWebRequestTransport,AtomicRefCounter,RedirectHelper,ResponseHelper,DownloadHandler,UploadHandler,CertificateHandler,HeaderHelper,AsyncOperation>::Job_InvokeCoroutine
0x00007FF6A162076A (Unity) BackgroundJobQueue::ExecuteMainThreadJobs
0x00007FF6A14B661C (Unity) Texture::VerifyFileTextureUploadCompletion
0x00007FF6A13F21E3 (Unity) Texture2D::VerifyFileTextureUploadCompletion
0x00007FF6A13E052F (Unity) Texture2D::AwakeFromLoad
0x00007FF6A1EC3C47 (Unity) AwakeFromLoadQueue::InvokePersistentManagerAwake
0x00007FF6A1EC479E (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad
0x00007FF6A1EC482A (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad
0x00007FF6A1E5D165 (Unity) PersistentManager::IntegrateAllThreadedObjects
0x00007FF6A1E5D8A0 (Unity) PersistentManager::LoadAndIntegrateAllPreallocatedObjects
0x00007FF6A1E5E624 (Unity) PersistentManager::LoadObjects
0x00007FF6A0B0F514 (Unity) ProcessAssetBundleEntries
0x00007FF6A0B0E38D (Unity) LoadNamedObjectFromAssetBundle
0x00007FF6A0AFCA60 (Unity) AssetBundle::LoadAsset_Internal
0x00007FF6A0D73BDA (Unity) AssetBundle_CUSTOM_LoadAsset_Internal
0x0000019E4C2408DC (UnityEngine.AssetBundleModule) UnityEngine.AssetBundle.LoadAsset_Internal()
0x0000019E4C240743 (UnityEngine.AssetBundleModule) UnityEngine.AssetBundle.LoadAsset()
0x0000019E47A2705B (UnityEngine.AssetBundleModule) UnityEngine.AssetBundle.LoadAsset()
0x0000019E47A260A3 (Assembly-CSharp) AssetbundleManager.DealLoadRequest()
0x0000019E47A25CA3 (Assembly-CSharp) AssetbundleManager.OnFinishLoad()
0x0000019E47999B0B (Assembly-CSharp) <OnLoadAssetBundle>d__19.MoveNext()
0x0000019E479987CC (UnityEngine.CoreModule) UnityEngine.SetupCoroutine.InvokeMoveNext()
0x0000019E479988F7 (UnityEngine.CoreModule) <Module>.runtime_invoke_void_object_intptr()
0x00007FF8BE93D8C0 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke
0x00007FF8BE8C2912 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2921] do_runtime_invoke
0x00007FF8BE8CB96F (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2968] mono_runtime_invoke
0x00007FF6A1DCFD44 (Unity) scripting_method_invoke
0x00007FF6A1DC986B (Unity) ScriptingInvocation::Invoke
0x00007FF6A1D8AC90 (Unity) Coroutine::Run
0x00007FF6A1D8829C (Unity) Coroutine::ContinueCoroutine
0x00007FF6A174112B (Unity) AsyncOperation::InvokeCoroutine
0x00007FF6A257CDEC (Unity) UnityWebRequestAsyncOperation::InvokeCoroutine
0x00007FF6A257CFC9 (Unity) UnityWebRequestProto<UnityWebRequestTransport,AtomicRefCounter,RedirectHelper,ResponseHelper,DownloadHandler,UploadHandler,CertificateHandler,HeaderHelper,AsyncOperation>::Job_InvokeCoroutine
0x00007FF6A162076A (Unity) BackgroundJobQueue::ExecuteMainThreadJobs
0x00007FF6A174CCF2 (Unity) `InitPlayerLoopCallbacks'::`2'::EarlyUpdateExecuteMainThreadJobsRegistrator::Forward
0x00007FF6A17363F9 (Unity) ExecutePlayerLoop
0x00007FF6A17364D0 (Unity) ExecutePlayerLoop
0x00007FF6A173B98C (Unity) PlayerLoop
0x00007FF6A29CC2AE (Unity) PlayerLoopController::UpdateScene
0x00007FF6A29CB4A0 (Unity) Application::TickTimer
0x00007FF6A31CD2D4 (Unity) MainMessageLoop
0x00007FF6A31D666E (Unity) WinMain
0x00007FF6A4E514A6 (Unity) __scrt_common_main_seh
0x00007FF90DC37034 (KERNEL32) BaseThreadInitThunk
0x00007FF90F91D0D1 (ntdll) RtlUserThreadStart
Comment