【发布时间】:2020-05-16 20:59:41
【问题描述】:
我正在 Unity 中构建一个包含许多场景(AKA 关卡)的手机游戏,我还打算在游戏生命周期的后期通过更新添加更多关卡。为了解决这个问题,我尝试制作一个自动化脚本,查看 Unity 构建中有多少场景,并基于预制件创建相应的 UI 按钮。
为了清楚起见,我会注意,当我说“Unity Build 中的场景”时,我指的是构建菜单中的场景:
并且已经有了索引号。
这不是很多,但这是我当前的脚本,我在场景中有一个 levelManager:
private Scene[] levels;
private void Start()
{
/// This is the line I'm requesting help with
levels = // Some way of getting all the scene's in a project put in an array
foreach (var item in levels)
{
// I will handle the button creation and modification later that will go here
}
}
【问题讨论】: