如何在Unity中的2D画布上播放3D动画 [英] How to play 3D animation on a 2D canvas in Unity
本文介绍了如何在Unity中的2D画布上播放3D动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我喜欢在Canvas上播放动画.
I like to play animation on a Canvas.
我制作了一个画布,如下图所示.
I made a canvas as shown in the following image.
我喜欢在绿色画布上播放高尔夫球手动画. 有可能吗?
I like to play a golfer animation on the green color canvas. Is it possible?
我有第二个图所示的动画模型.
I have animation model as shown in the second figure.
我喜欢在画布上播放高尔夫球手的动画. 我怎样才能做到这一点? 我将画布作为子对象拖放到画布下,这是行不通的.
I like to play that golfer animation on the canvas. How can I do that? I drag and put under canvas as child object, it doesn't work.
推荐答案
正如我在评论中所解释的,我将按照以下说明进行操作:
As I explained in my comment, I would do as follow :
- 将您的对象放置在特定的图层中(在示例中称为
MyLayer
) - 将新相机的
Culling mask
设置为仅渲染此特定图层 - 取消选中主相机的
Culling mask
中的MyLayer
,以防止后者渲染您的模型 - 将摄像机的
Clear flags
设置为Depth only
以防止后者渲染天空盒 - 在您的项目中创建一个新的渲染纹理,然后将&将其放置在新相机的
Render Texture
字段中 - 将新的原始图像添加到您的UI画布并分配渲染
Texture
字段中的纹理 - 运行3D动画
- Put your object in a specific layer (called
MyLayer
for the sake of the example) - Set the
Culling mask
of a new camera to render only this specific layer - Uncheck the
MyLayer
in theCulling mask
of your main camera in order to prevent the latter to render your model - Set the
Clear flags
toDepth only
of the camera to prevent the latter from rendering the skybox - Create a new Render texture in your project, and drag & drop it in the
Render Texture
field of your new Camera - Add a new Raw Image to your UI canvas and assign the render texture in the
Texture
field - Run your 3D animation
您的相机会将动画渲染到UI上的图像中
Your camera will render the animation into the image on your UI
这篇关于如何在Unity中的2D画布上播放3D动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文