ui 在 Unity 的协程中更改 canvas localScale 时出现问题

ui problems when changing canvas localScale in coroutine in Unity

我在更改 Canvas 的 localScale 时遇到问题。 首先,我想设计一个在坦克war游戏中购买equipments的功能,所以我添加了一个canvas来显示equipments。 canvas的结构如下: canvas ui structure

游戏开始时,我在协程中将canvas的localScale在一段时间内从(0,0,0)改为(1,1,1)。代码显示如下:

private IEnumerator DampCanvas(){
        float dis = Vector3.Distance (rect.localScale, Vector3.one);
        while (dis >= threshold) {
            rect.localScale = 
                Vector3.SmoothDamp (rect.localScale, Vector3.one, ref eqpsSmoothVec, eqpsSmoothTime);
            dis = Vector3.Distance (rect.localScale, Vector3.one);
            yield return null;
        }
        rect.localScale = Vector3.one;
    }

协程运行正常,但我在协程之前做了如下操作:

但问题是在 ui 上添加的 equipments 不显示,但我确实在层次结构视图中看到了 ui 对象。

beginning of the game

hierarchy view

我刚学了一段时间的 unity,不知道是什么happened.Can有人帮我吗?

我会检查未显示的 gamobjects 是否已启用(启用检查器左上角的复选框)+它们的渲染组件也已启用。此外,它们在场景层次结构中没有任何 parent 比例 = (0,0,0)(变换参数是 parent 相对的,因此如果 parent 的比例为(0 ,0,0) 这将传递给 children,因此 children 不会显示)