Closed guoguoguilai closed 4 years ago
你好 ,如果想在UI上显示3D内容可以参考如下代码:
Widget videoTexture() { var texture = Resources.Load<RenderTexture>("VideoSampleRT"); return new Center( child: new Container( width: 240, height: 135, child: new Texture(texture: texture) ) ); }
您好!我想实现一个UI中显示3D场景的功能,看到UnityConnect中有关于这部分的回答。 但当我打开TodoAppPanel的场景的时候,在Unity2018.3.10f1中提示
AssertionError: Window.instance is null. This usually happens when there is a callback from outside of UIWidgets. Try to use "using (WindowProvider.of(BuildContext).getScope()) { ... }" to wrap your code. Unity.UIWidgets.ui.Window.get_instance () (at Packages/com.unity.uiwidgets/Runtime/ui/window.cs:114) Unity.UIWidgets.editor.WindowAdapter.scheduleFrame (System.Boolean regenerateLayerTree) (at Packages/com.unity.uiwidgets/Runtime/editor/editor_window.cs:527) Unity.UIWidgets.engine.UIWidgetWindowAdapter.scheduleFrame (System.Boolean regenerateLayerTree) (at Packages/com.unity.uiwidgets/Runtime/engine/UIWidgetsPanel.cs:32) Unity.UIWidgets.widgets.Texture+<>c.<textureFrameAvailable>b__0_0 (Unity.UIWidgets.editor.WindowAdapter w) (at Packages/com.unity.uiwidgets/Runtime/widgets/texture.cs:10) System.Collections.Generic.List
1[T].ForEach (System.Action1[T] action) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0) Unity.UIWidgets.widgets.Texture.textureFrameAvailable (Unity.UIWidgets.ui.Window instance) (at Packages/com.unity.uiwidgets/Runtime/widgets/texture.cs:10) UIWidgetsSample.VideoSampleComponent+<>c.<Start>b__2_0 (UnityEngine.Video.VideoPlayer _, System.Int64 __) (at <54df9a5cc45f4251af72d8d6f1e691bd>:0) UnityEngine.Video.VideoPlayer.InvokeFrameReadyCallback_Internal (UnityEngine.Video.VideoPlayer source, System.Int64 frameIdx) (at D:/unity/Modules/Video/Public/ScriptBindings/VideoPlayer.bindings.cs:294)
在Unity2018.4.10f1中提示NullReferenceException: Object reference not set to an instance of an object Unity.UIWidgets.editor.WindowAdapter.scheduleFrame (System.Boolean regenerateLayerTree) (at Packages/com.unity.uiwidgets/Runtime/editor/editor_window.cs:527) Unity.UIWidgets.engine.UIWidgetWindowAdapter.scheduleFrame (System.Boolean regenerateLayerTree) (at Packages/com.unity.uiwidgets/Runtime/engine/UIWidgetsPanel.cs:32) Unity.UIWidgets.widgets.Texture+<>c.<textureFrameAvailable>b__0_0 (Unity.UIWidgets.editor.WindowAdapter w) (at Packages/com.unity.uiwidgets/Runtime/widgets/texture.cs:10) System.Collections.Generic.List
1[T].ForEach (System.Action1[T] action) (at <7ba07f088431485bb722f3b3373e87ee>:0) Unity.UIWidgets.widgets.Texture.textureFrameAvailable (Unity.UIWidgets.ui.Window instance) (at Packages/com.unity.uiwidgets/Runtime/widgets/texture.cs:10) UIWidgetsSample.VideoSampleComponent+<>c.<Start>b__2_0 (UnityEngine.Video.VideoPlayer _, System.Int64 __) (at <ea31cc249a884a059109c44f45aca870>:0) UnityEngine.Video.VideoPlayer.InvokeFrameReadyCallback_Internal (UnityEngine.Video.VideoPlayer source, System.Int64 frameIdx) (at C:/buildslave/unity/build/Modules/Video/Public/ScriptBindings/VideoPlayer.bindings.cs:294)
虽然您在Readme中提到过解决方案,但我还是不太清楚如何下手,所以想请教一下 谢谢~