セットアップが完了していないBakedDataをTimelineに置いたときに発生するエラーを修正 #48
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
概要
セットアップが完了していないBakedDataをTimelineに置いたときに
Texture2D.whiteTextureをDestroyしようとしてエラーが発生していました。セットアップが完了していない場合は
Texture2D.whiteTextureではなく、new Texture2D(width, height)を返すようにしました。補足
Object.Instantiate(Texture2D.whiteTexture)を使った方法この方法で作成されるテクスチャは4x4のサイズなため、
uLipSyncClipTimelineEditor.GetOrCreateCachedTexture()でキャッシュされたテクスチャと描画したいテクスチャのサイズが常に異なり、毎回テクスチャを再生成するようになってしまうため採用しませんでした。懸念点
Textrue2Dをnewした場合はRGBAが全て205のテクスチャが作成されますが、恐らくこの仕様はドキュメントに記載されていないため明示的に白で埋めたほうがきれいかもしれません。
(今回は、あまり本質的でない処理内容が多くなってしまうため実装はしませんでした)
発生するエラー
エラー全文
Destroying object "UnityWhite" is not allowed at this time.
0x00007ff6922ba53d (Unity) StackWalker::GetCurrentCallstack
0x00007ff6922c1299 (Unity) StackWalker::ShowCallstack
0x00007ff693225de3 (Unity) GetStacktrace
0x00007ff6938af47d (Unity) DebugStringToFile
0x00007ff691e876e1 (Unity) CheckAllowDestruction
0x00007ff6921d7651 (Unity) Scripting::DestroyObjectFromScriptingImmediate
0x00007ff69142bce3 (Unity) Object_CUSTOM_DestroyImmediate
0x000001d9f37d6acc (Mono JIT Code) (wrapper managed-to-native) UnityEngine.Object:DestroyImmediate (UnityEngine.Object,bool)
0x000001d9f37d696b (Mono JIT Code) UnityEngine.Object:DestroyImmediate (UnityEngine.Object)
0x000001db2e635493 (Mono JIT Code) [uLipSyncClipEditor.cs:80] uLipSync.Timeline.uLipSyncClipTimelineEditor:RemoveCachedTexture (uLipSync.Timeline.uLipSyncClip)
0x000001db2e634fbb (Mono JIT Code) [uLipSyncClipEditor.cs:86] uLipSync.Timeline.uLipSyncClipTimelineEditor:CreateCachedTexture (uLipSync.Timeline.uLipSyncClip,int,int)
0x000001db2e634df3 (Mono JIT Code) [uLipSyncClipEditor.cs:116] uLipSync.Timeline.uLipSyncClipTimelineEditor:GetOrCreateCachedTexture (uLipSync.Timeline.uLipSyncClip,int,int)
0x000001db2e6347db (Mono JIT Code) [uLipSyncClipEditor.cs:153] uLipSync.Timeline.uLipSyncClipTimelineEditor:DrawWave (UnityEngine.Timeline.TimelineClip,UnityEditor.Timeline.ClipBackgroundRegion)
0x000001db2e631783 (Mono JIT Code) [uLipSyncClipEditor.cs:125] uLipSync.Timeline.uLipSyncClipTimelineEditor:DrawBackground (UnityEngine.Timeline.TimelineClip,UnityEditor.Timeline.ClipBackgroundRegion)
0x000001db2e616952 (Mono JIT Code) [ClipDrawer.cs:619] UnityEditor.Timeline.ClipDrawer:DrawClipEditorBackground (UnityEditor.Timeline.ClipDrawData)
0x000001db2e610b9b (Mono JIT Code) [ClipDrawer.cs:564] UnityEditor.Timeline.ClipDrawer:DrawDefaultClip (UnityEditor.Timeline.ClipDrawData)
0x000001db0c60f0fb (Mono JIT Code) [TimelineClipGUI.cs:322] UnityEditor.Timeline.TimelineClipGUI:DrawClip (UnityEditor.Timeline.ClipDrawData)
0x000001da4bcadceb (Mono JIT Code) [TimelineClipGUI.cs:379] UnityEditor.Timeline.TimelineClipGUI:DrawInto (UnityEngine.Rect,UnityEditor.Timeline.WindowState)
0x000001da4bca2b63 (Mono JIT Code) [TimelineClipGUI.cs:459] UnityEditor.Timeline.TimelineClipGUI:Draw (UnityEngine.Rect,bool,UnityEditor.Timeline.WindowState)
0x000001da4bca0e1d (Mono JIT Code) [ItemsLayer.cs:96] UnityEditor.Timeline.ItemsLayer
1<T_REF>:Draw (UnityEngine.Rect,UnityEditor.Timeline.WindowState) 0x000001da4bca04bb (Mono JIT Code) [ClipsLayer.cs:39] UnityEditor.Timeline.ClipsLayer:Draw (UnityEngine.Rect,UnityEditor.Timeline.WindowState) 0x000001da4bca0229 (Mono JIT Code) [TrackItemsDrawer.cs:34] UnityEditor.Timeline.TrackItemsDrawer:Draw (UnityEngine.Rect,UnityEditor.Timeline.WindowState) 0x000001da4bc9828b (Mono JIT Code) [TimelineTrackGUI.cs:297] UnityEditor.Timeline.TimelineTrackGUI:Draw (UnityEngine.Rect,UnityEngine.Rect,UnityEditor.Timeline.WindowState) 0x000001da4bc8ebca (Mono JIT Code) [TimelineTreeView.cs:192] UnityEditor.Timeline.TimelineTreeView:OnRowGUI (UnityEngine.Rect,UnityEditor.IMGUI.Controls.TreeViewItem,int,bool,bool) 0x000001da4bc8d090 (Mono JIT Code) UnityEditor.IMGUI.Controls.TreeViewController:DoItemGUI (UnityEditor.IMGUI.Controls.TreeViewItem,int,single,bool) 0x000001da4bc8c2eb (Mono JIT Code) UnityEditor.IMGUI.Controls.TreeViewController:IterateVisibleItems (int,int,single,bool) 0x000001da4bc76443 (Mono JIT Code) UnityEditor.IMGUI.Controls.TreeViewController:OnGUI (UnityEngine.Rect,int) 0x000001da4bc720fb (Mono JIT Code) [TimelineTreeViewGUI.cs:152] UnityEditor.Timeline.TimelineTreeViewGUI:OnGUI (UnityEngine.Rect) 0x000001da4bc7174b (Mono JIT Code) [TimelineWindow_TrackGui.cs:133] UnityEditor.Timeline.TimelineWindow:DrawTracksGUI (UnityEngine.Rect,UnityEditor.Timeline.TimelineModeGUIState) 0x000001da4bc6f24b (Mono JIT Code) [TimelineWindow_TrackGui.cs:47] UnityEditor.Timeline.TimelineWindow:TracksGUI (UnityEngine.Rect,UnityEditor.Timeline.WindowState,UnityEditor.Timeline.TimelineModeGUIState) 0x000001da4bc6dd13 (Mono JIT Code) [TimelineWindow_Gui.cs:200] UnityEditor.Timeline.TimelineWindow:TrackViewsGUI () 0x000001da4bc14693 (Mono JIT Code) [TimelineWindow_Gui.cs:296] UnityEditor.Timeline.TimelineWindow:SequencerGUI () 0x000001da4bc13f53 (Mono JIT Code) [TimelineWindow_Gui.cs:165] UnityEditor.Timeline.TimelineWindow:DoLayout () 0x000001da4bb9a643 (Mono JIT Code) [TimelineWindow.cs:226] UnityEditor.Timeline.TimelineWindow:OnGUI () 0x000001da4bb94e59 (Mono JIT Code) UnityEditor.HostView:InvokeOnGUI (UnityEngine.Rect) 0x000001da4bb94993 (Mono JIT Code) UnityEditor.DockArea:DrawView (UnityEngine.Rect) 0x000001da44623eb3 (Mono JIT Code) UnityEditor.DockArea:OldOnGUI () 0x000001da44421ae1 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:DoOnGUI (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,bool,UnityEngine.Rect,System.Action,bool) 0x000001da4422adf3 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,System.Action,bool) 0x000001dafddfd47b (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:DoIMGUIRepaint () 0x000001dafddf807a (Mono JIT Code) UnityEngine.UIElements.UIR.RenderChainCommand:ExecuteNonDrawMesh (UnityEngine.UIElements.UIR.DrawParams,single,System.Exception&) 0x000001dafddf4d2b (Mono JIT Code) UnityEngine.UIElements.UIR.UIRenderDevice:EvaluateChain (UnityEngine.UIElements.UIR.RenderChainCommand,UnityEngine.Material,UnityEngine.Material,UnityEngine.Texture,UnityEngine.Texture,single,Unity.Collections.NativeSlice1<UnityEngine.UIElements.UIR.Transform3x4>,Unity.Collections.NativeSlice`1<UnityEngine.Vector4>,UnityEngine.MaterialPropertyBlock,bool,System.Exception&)0x000001dafdde81fb (Mono JIT Code) UnityEngine.UIElements.UIR.RenderChain:Render ()
0x000001dafdda07c3 (Mono JIT Code) UnityEngine.UIElements.UIRRepaintUpdater:Update ()
0x000001da4412bcfa (Mono JIT Code) UnityEngine.UIElements.VisualTreeUpdater:UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase)
0x000001dafdd9dc93 (Mono JIT Code) UnityEngine.UIElements.Panel:UpdateForRepaint ()
0x000001dafdd99df3 (Mono JIT Code) UnityEngine.UIElements.Panel:Repaint (UnityEngine.Event)
0x000001da4412a941 (Mono JIT Code) UnityEngine.UIElements.UIElementsUtility:DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel)
0x000001da4412a293 (Mono JIT Code) UnityEngine.UIElements.UIElementsUtility:UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (int,intptr,bool&)
0x000001da44129c84 (Mono JIT Code) UnityEngine.UIElements.UIEventRegistration:ProcessEvent (int,intptr)
0x000001da4412999b (Mono JIT Code) UnityEngine.UIElements.UIEventRegistration/<>c:<.cctor>b__1_2 (int,intptr)
0x000001da44129445 (Mono JIT Code) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
0x000001da44129686 (Mono JIT Code) (wrapper runtime-invoke) :runtime_invoke_void_int_intptr_intptr& (object,intptr,intptr,intptr)
0x00007ffb4560e0a4 (mono-2.0-bdwgc) [mini-runtime.c:3445] mono_jit_runtime_invoke
0x00007ffb4554e744 (mono-2.0-bdwgc) [object.c:3066] do_runtime_invoke
0x00007ffb4554e8dc (mono-2.0-bdwgc) [object.c:3113] mono_runtime_invoke
0x00007ff6921decf4 (Unity) scripting_method_invoke
0x00007ff6921d9914 (Unity) ScriptingInvocation::Invoke
0x00007ff6921d3235 (Unity) ScriptingInvocation::Invoke
0x00007ff6922dbe2a (Unity) Scripting::UnityEngine::GUIUtilityProxy::ProcessEvent
0x00007ff692d12396 (Unity) GUIView::ProcessRetainedMode
0x00007ff6932562ab (Unity) GUIView::OnInputEvent
0x00007ff692d121aa (Unity) GUIView::ProcessInputEvent
0x00007ff69324f04e (Unity) GUIView::DoPaint
0x00007ff69325843d (Unity) GUIView::RepaintAll
0x00007ff692de5d76 (Unity) PlayerLoopController::UpdateScene
0x00007ff692de3d5f (Unity) Application::TickTimer
0x00007ff69322bf7a (Unity) MainMessageLoop
0x00007ff69323084b (Unity) WinMain
0x00007ff694551d4e (Unity) __scrt_common_main_seh
0x00007ffc0bf626ad (KERNEL32) BaseThreadInitThunk
0x00007ffc0dbcaa68 (ntdll) RtlUserThreadStart
再現方法