在Unity Engine中,有人知道如何更改网格布局组子元素的绘制顺序(相反的绘制顺序),所以我想保持元素当前的位置顺序,但我想将网格布局组对象的子对象更改为与通常相反的渲染顺序。所以不是绘制子代0,1,2(渲染在顶部)-我想要它的子代2,1,0(渲染在顶部)。我必须强调,我不想改变相对于Grid Layout Group父游戏对象的孩子的实际顺序。
发布于 2020-05-02 16:58:18
粗暴的方法是为每个子对象创建一个UI material实例,并手动设置队列。
发布于 2020-05-02 18:28:26
可以使用以下方法调整渲染顺序:
transform.SetAsLastSibling (); // Element is displayed on the top.
transform.SetAsFirstSibling (); // Element is displayed last.
transform.SetSiblingIndex (7); // Element is displayed based on an index
transform.GetSiblingIndex ();发布于 2021-05-30 21:17:27
将画布直接添加到元素中,将overrideSorting设置为true并手动设置顺序。
此外,要使其他功能正常工作,请添加一个图形raycaster组件
来自https://www.reddit.com/r/Unity3D/comments/7psox8/ui_element_render_order_in_grid_layout/
https://stackoverflow.com/questions/61556242
复制相似问题