在Android应用程序中拍摄Unity场景的屏幕截图

在Android应用程序中拍摄Unity场景的屏幕截图,android,unity3d,Android,Unity3d,我的Android应用程序中有一个Unity场景作为视图的一部分。这是我从Unity editor导出项目后设置它的方式 protected void onCreate(Bundle savedInstanceState) { this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); super.onCreate(savedInstanceState); mUnityPlayer =

我的Android应用程序中有一个Unity场景作为视图的一部分。这是我从Unity editor导出项目后设置它的方式

protected void onCreate(Bundle savedInstanceState) {
    this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

    super.onCreate(savedInstanceState);
    mUnityPlayer = new UnityPlayer(this);
    binding = DataBindingUtil.setContentView(this, R.layout.main);

    mUnityPlayer.setBackgroundResource(R.drawable.some_drawable);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    binding.scene.addView(mUnityPlayer.getView(), 0, lp);
}
这个很好用。现在我需要拍摄这个场景的屏幕截图,并在另一个
ImageView
中显示它。问题是UnityPlayer是一个
FrameLayout
,我希望在上面使用
getDrawingCache()
来获取屏幕截图

但这只会返回我的背景图像
R.drawable。Unity场景中的一些可绘制的
以及任何文本和其他信息都不会出现在屏幕截图中。我认为这可能是因为其他内容不是FrameLayout的一部分,而是在一些
TextureView
或其他东西上呈现的。我可能完全错了。但我不知道如何将场景中的内容截图设置为
位图
,我可以在另一个
图像视图
上进行设置


任何指点或帮助都将不胜感激。谢谢

请提供一些图片。你可以从Unity player(screen Capture.CaptureScreenshot)制作一个屏幕截图并使用它。