Änderung am 28.02.2025 getroffen.

This commit is contained in:
2025-03-01 19:08:48 +01:00
parent 58508e4dec
commit 6f7c117ad1
134 changed files with 5488 additions and 4 deletions

View File

@@ -0,0 +1,50 @@
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Link zum OG Script: https://pastebin.com/DG5jcAMZ
/// </summary>
public class ParallaxBackground : MonoBehaviour
{
public ParallaxCamera parallaxCamera;
List<ParallaxLayer> parallaxLayers = new List<ParallaxLayer>();
void Start()
{
if (parallaxCamera == null)
{
parallaxCamera = Camera.main.GetComponent<ParallaxCamera>();
}
if (parallaxCamera != null)
{
parallaxCamera.onCameraTranslate += Move;
}
SetLayers();
void SetLayers()
{
parallaxLayers.Clear();
for (int i = 0; i < transform.childCount; i++)
{
ParallaxLayer layer = transform.GetChild(i).GetComponent<ParallaxLayer>();
if (layer != null)
{
layer.name = "Layer-" + i;
parallaxLayers.Add(layer);
}
}
}
void Move(float delta)
{
foreach (ParallaxLayer layer in parallaxLayers)
{
layer.Move(delta);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 122e101a488bab94a9185d5075950bd8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
using UnityEngine;
/// <summary>
/// Link zum OG Script: https://pastebin.com/jD62XeKQ
/// </summary>
///
public class ParallaxCamera : MonoBehaviour
{
// delegate -> type; safely encapsulate a method
public delegate void ParallaxCameraDelegate(float deltaMovement);
public ParallaxCameraDelegate onCameraTranslate;
private float oldPosition;
void Start()
{
oldPosition = transform.position.x;
}
void Update()
{
if (transform.position.x != oldPosition)
{
if (onCameraTranslate != null)
{
float delta = oldPosition - transform.position.x;
onCameraTranslate(delta);
}
oldPosition = transform.position.x;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 604646cef6bf39c439fc4b3ef6449410
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using UnityEngine;
/// <summary>
/// Link zum OG Script: https://pastebin.com/ZniykeGz
/// </summary>
public class ParallaxLayer : MonoBehaviour
{
public float parallaxFactor;
public void Move(float delta)
{
Vector3 newPos = transform.localPosition;
newPos.x -= delta * parallaxFactor;
transform.localPosition = newPos;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 22a3a2280dd7edb439a442cc313afe32
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: