A lot of stuff to Commit because I forgot to Commit in between (Don't do stuff like this, kids)
This commit is contained in:
@@ -31,12 +31,40 @@ public class SceneSwitcher : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private GameObject[] _deactivateChildrenOf;
|
||||
|
||||
public void SwitchScene(int sceneIndex)
|
||||
{
|
||||
for (var i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
transform.GetChild(i).gameObject.SetActive(i == sceneIndex);
|
||||
}
|
||||
|
||||
foreach (var toDeactivate in _deactivateChildrenOf)
|
||||
{
|
||||
foreach (Transform child in toDeactivate.transform)
|
||||
{
|
||||
child.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SwitchToNext()
|
||||
{
|
||||
for (var i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
if (transform.GetChild(i).gameObject.activeSelf)
|
||||
{
|
||||
var nextIndex = i + 1;
|
||||
if (nextIndex >= transform.childCount)
|
||||
{
|
||||
nextIndex = 0;
|
||||
}
|
||||
SwitchScene(nextIndex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<(string name, int index)> GetScenes()
|
||||
@@ -49,4 +77,8 @@ public class SceneSwitcher : MonoBehaviour
|
||||
}
|
||||
return scenes;
|
||||
}
|
||||
public GameObject GetGameObject(int sceneIndex)
|
||||
{
|
||||
return transform.GetChild(sceneIndex).gameObject;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user