WorldSpace Canvas上的动画师

时间:2016-04-15 10:54:50

标签: c# animation unity3d unity5

好的,所以我的世界空间画布附在玩家对象上。在我的脚本中,我有这样的参考:

 GameObject myWorldCanvas;

Awake()
{
 myWorldCanvas= transform.FindChild("nameOfObject").gameObject;
}

然后,当满足正确的条件时,我只需激活这样的对象:

myWorldCanvas.SeActive(true);

在我向对象添加动画师之前,这一功能完美无缺。如果我手动启用/禁用场景中的对象,动画效果很好(它只是更改比例以使其具有弹出效果),但是当我的脚本激活对象时,动画仍会播放并更改比例值,但没有任何内容渲染。在播放模式下,如果我手动启用/禁用动画工作。

有什么想法吗?如果您需要更多信息或屏幕,请告诉我。

编辑:画布上有一些按钮作为子画面,当我将鼠标悬停在某物上时,似乎会刷新并且图像会显示在屏幕上。

编辑:进一步测试显示手动禁用和启用Canvas组件也会显示图像,但如果从脚本启用了画布和游戏对象,则屏幕上不会显示任何内容。

编辑:我解决了这个问题,方法是在动画的第一个键上禁用画布组件,然后在Y刻度设置为0的第二个键上启用它。这看起来更像是黑客,我不喜欢它。有谁知道为什么会这样?

2 个答案:

答案 0 :(得分:0)

I know this problem. It is because Unity's feature of the animation window.

The animation window allows you to record the states of your objects into your animations. This can be turned off by pressing the red circle toggle on the top-left corner of the animation window. But if you forget to do that, it will automatically record your every single action, including activating and deactivating the canvas.

This is quite an annoying feature, but I don't know how to disable. So just remember to close the animation window when you don't use.

答案 1 :(得分:0)

好的问题是动画是在xyz轴上从0缩放画布。更改动画以从0.1开始缩放,解决了问题。