diff --git a/Assets/BackButton.cs b/Assets/BackButton.cs new file mode 100644 index 0000000..38d47dc --- /dev/null +++ b/Assets/BackButton.cs @@ -0,0 +1,20 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class BackButton : MonoBehaviour +{ + public GameObject[] objectsToDeactivate; + public GameObject[] objectsToActivate; + public void GoBack() + { + for (int i = 0; i < objectsToActivate.Length; i++) + { + objectsToActivate[i].SetActive(true); // activate the game object + } + for (int i = 0; i < objectsToDeactivate.Length; i++) + { + objectsToDeactivate[i].SetActive(false); // deactivate the game object + } + } +} diff --git a/Assets/Exit.cs b/Assets/Exit.cs new file mode 100644 index 0000000..98d2313 --- /dev/null +++ b/Assets/Exit.cs @@ -0,0 +1,17 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.SceneManagement; + +public class Exit : MonoBehaviour +{ + public string sceneName; + + // To change the scene by name + public void changeScene() + { + Debug.Log("Taste exit wurde gedrückt!"); + SceneManager.LoadScene(sceneName); + } +} + diff --git a/Assets/Galaxy/Galaxy.cs b/Assets/Galaxy/Galaxy.cs new file mode 100644 index 0000000..1b86fa9 --- /dev/null +++ b/Assets/Galaxy/Galaxy.cs @@ -0,0 +1,22 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class Galaxy : MonoBehaviour +{ + [SerializeField] private RawImage _img; + [SerializeField] private float _x, _y; + + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + _img.uvRect = new Rect(_img.uvRect.position + new Vector2(_x, _y) * Time.deltaTime, _img.uvRect.size); + } +} diff --git a/Assets/Galaxy/Sun Red.png b/Assets/Galaxy/Sun Red.png new file mode 100644 index 0000000..12333ba Binary files /dev/null and b/Assets/Galaxy/Sun Red.png differ diff --git a/Assets/Galaxy/galaxy.jpg b/Assets/Galaxy/galaxy.jpg new file mode 100644 index 0000000..0b9fef7 Binary files /dev/null and b/Assets/Galaxy/galaxy.jpg differ diff --git a/Assets/GalaxyContainer.cs b/Assets/GalaxyContainer.cs new file mode 100644 index 0000000..19762cc --- /dev/null +++ b/Assets/GalaxyContainer.cs @@ -0,0 +1,124 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class GalaxyContainer : MonoBehaviour +{ + public GameObject[] objects; + public GameObject galaxyPrefab; // Prefab des Galaxy-Objekts + public int numberOfGalaxies; // Anzahl der zu erstellenden Galaxien + public float distanceFromCenter; // Abstand der Galaxien vom Hauptobjekt + + void Start() + { + Vector3 centerPosition = transform.position; // Position des Hauptobjekts + + // Berechne die Anzahl der Zeilen und Spalten basierend auf der Anzahl der Galaxien + int rows = Mathf.CeilToInt(Mathf.Sqrt(numberOfGalaxies)); + int columns = Mathf.CeilToInt((float)numberOfGalaxies / rows); + + // Berechne den Abstand zwischen den Galaxien auf jeder Achse + float xSpacing = distanceFromCenter / (columns - 1); + float ySpacing = distanceFromCenter / (rows - 1); + + // Erstelle alle Galaxien + for (int i = 0; i < numberOfGalaxies; i++) + { + // Berechne die x- und y-Position basierend auf dem Index + int rowIndex = i % rows; + int columnIndex = i / rows; + + // Berechne die Position basierend auf den Indizes und den Abständen + float xPos = centerPosition.x - (distanceFromCenter / 2f) + columnIndex * xSpacing; + float yPos = centerPosition.y - (distanceFromCenter / 2f) + rowIndex * ySpacing; + + // Erzeuge ein neues GameObject aus dem Prefab + GameObject galaxy = Instantiate(galaxyPrefab); + + // Setze die Position des Galaxy-Objekts + galaxy.transform.position = new Vector3(xPos, yPos, centerPosition.z); + } + } + + + + + + + + + /*void Start() + { + for (int i = 0; i < objectsToDeactivate0.Length; i++) + { + objectsToDeactivate0[i].SetActive(false); // Deactivate the game object + } + + // Erstelle für jeden Button ein Raw Image + for (int i = 0; i < planetTextures.Length; i++) + { + // Erzeuge ein neues GameObject für den Button + GameObject buttonGO = new GameObject("Button" + i); + buttonGO.transform.SetParent(transform); + + // Füge das Raw Image Komponente hinzu + RawImage rawImage = buttonGO.AddComponent(); + + // Weise die Planeten-Textur dem Raw Image zu + rawImage.texture = planetTextures[i]; + + // Setze die Position des Raw Images entsprechend der Button-Position + buttonGO.transform.localPosition = new Vector3(buttonPositions[i].x, buttonPositions[i].y, 0f); + + // Füge eine Button-Komponente hinzu + Button button = buttonGO.AddComponent