-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameManager.cs
More file actions
52 lines (46 loc) · 1.95 KB
/
Copy pathGameManager.cs
File metadata and controls
52 lines (46 loc) · 1.95 KB
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
using UnityEngine;
// V3: Restoring domino functionality on a stable base.
public class GameManager : MonoBehaviour
{
void Start()
{
Debug.Log("GameManager starting...");
// 1. Ensure we have a main camera.
Camera mainCamera = Camera.main;
if (mainCamera == null)
{
Debug.LogError("CRITICAL: No Main Camera found. Please ensure your scene has a camera tagged 'MainCamera'.");
return;
}
// Position the camera for a good view of the dominoes.
mainCamera.transform.position = new Vector3(0, 15, -20);
mainCamera.transform.rotation = Quaternion.Euler(45, 0, 0);
mainCamera.clearFlags = CameraClearFlags.Skybox; // Use default skybox for a nicer look.
// 2. Ensure we have a light.
if (FindObjectOfType<Light>() == null)
{
Debug.LogWarning("No light found in scene. Creating a default Directional Light.");
GameObject lightObj = new GameObject("Directional Light");
Light light = lightObj.AddComponent<Light>();
light.type = LightType.Directional;
lightObj.transform.rotation = Quaternion.Euler(50, -30, 0);
}
// 3. Create the ground plane.
GameObject ground = GameObject.CreatePrimitive(PrimitiveType.Plane);
ground.name = "Ground";
ground.transform.position = Vector3.zero;
ground.transform.localScale = new Vector3(10, 1, 10);
Debug.Log("Ground plane created.");
// 4. Add the other managers to the scene.
if (FindObjectOfType<DominoGenerator>() == null)
{
new GameObject("DominoGenerator").AddComponent<DominoGenerator>();
Debug.Log("DominoGenerator object created.");
}
if (FindObjectOfType<InputManager>() == null)
{
new GameObject("InputManager").AddComponent<InputManager>();
Debug.Log("InputManager object created.");
}
}
}