首页 > 其他分享 >Unity获取所有场景的名字

Unity获取所有场景的名字

时间:2023-02-26 13:33:16浏览次数:23  
标签:count 场景 string strs 获取 Unity sceneNamesArr str


/// <summary>获取所有场景名字</summary>
private string[] getAllSceneName()
{
int count = SceneManager.sceneCountInBuildSettings;
string[] sceneNamesArr = new string[count];
for (int i = 0; i < count; i++)
{
sceneNamesArr[i] = SceneUtility.GetScenePathByBuildIndex(i);
string[] strs = sceneNamesArr[i].Split('/');
string str = strs[strs.Length - 1];
strs = str.Split('.');
str = strs[0];
sceneNamesArr[i] = str;

Debug.Log("场景名字:" + str);
}

return sceneNamesArr;
}

标签:count,场景,string,strs,获取,Unity,sceneNamesArr,str
From: https://blog.51cto.com/u_14359474/6086409

相关文章