-
Notifications
You must be signed in to change notification settings - Fork 324
/
SceneControl.cs
81 lines (71 loc) · 2.61 KB
/
SceneControl.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Project: Daggerfall Unity
// Copyright: Copyright (C) 2009-2023 Daggerfall Workshop
// Web Site: http://www.dfworkshop.net
// License: MIT License (http://www.opensource.org/licenses/mit-license.php)
// Source Code: https://github.com/Interkarma/daggerfall-unity
// Original Author: Gavin Clayton (interkarma@dfworkshop.net)
// Contributors:
//
// Notes:
//
using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections;
namespace DaggerfallWorkshop.Game.Utility
{
/// <summary>
/// Launches game or startup scene based on path validation.
/// </summary>
public class SceneControl : MonoBehaviour
{
public const int StartupSceneIndex = 0;
public const int GameSceneIndex = 1;
public GameObject defaultSky = null;
void Start()
{
// Resolution
if (DaggerfallUnity.Settings.ExclusiveFullscreen && DaggerfallUnity.Settings.Fullscreen)
{
Screen.SetResolution(
DaggerfallUnity.Settings.ResolutionWidth,
DaggerfallUnity.Settings.ResolutionHeight,
FullScreenMode.ExclusiveFullScreen);
}
else
{
Screen.SetResolution(
DaggerfallUnity.Settings.ResolutionWidth,
DaggerfallUnity.Settings.ResolutionHeight,
DaggerfallUnity.Settings.Fullscreen);
}
// Check arena2 path is validated OK, otherwise start game setup
if (!DaggerfallUnity.Instance.IsPathValidated || DaggerfallUnity.Settings.ShowOptionsAtStart || Input.anyKey)
{
// Enable sky for test models
if (defaultSky != null)
defaultSky.SetActive(true);
// Post message to launch game setup
DaggerfallUI.PostMessage(DaggerfallUIMessages.dfuiSetupGameWizard);
}
else
{
SceneManager.LoadScene(GameSceneIndex);
}
}
//if scenes not in build menu, not guarenteed to be correct!
public static int GetCurrentSceneIndex()
{
int index = SceneManager.GetActiveScene().buildIndex;
DaggerfallUnity.LogMessage("scene index = " + index, false);
return index;
}
public static bool StartupSceneLoaded()
{
return GetCurrentSceneIndex() == StartupSceneIndex;
}
public static bool GameSceneLoaded()
{
return GetCurrentSceneIndex() == GameSceneIndex;
}
}
}