Änderungen am 15.03.2025 um 03:58 Uhr zuhause getroffen.

(Mache nach 2-4h Schlaf weiter. Noch nicht ganz fertig, aufgrund aufgrund mangelnder Zeit durch Arbeit, damaligen privaten Problemen und damals zu viel vorgenommen).
This commit is contained in:
2025-03-15 03:58:28 +01:00
parent 823261e1b0
commit 8b29c36c54
209 changed files with 19442 additions and 5386 deletions

View File

@@ -0,0 +1,49 @@
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Move each layer
/// Original script: https://pastebin.com/DG5jcAMZ.
/// YouTube link: https://youtu.be/MEy-kIGE-lI.
/// </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: badcee902c601654880e5774b7ec2a44
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,34 @@
using UnityEngine;
/// <summary>
/// Move each layer
/// Original script: https://pastebin.com/jD62XeKQ.
/// YouTube link: https://youtu.be/MEy-kIGE-lI.
/// </summary>
public class ParallaxCamera : MonoBehaviour
{
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: 31483aaf647030c49b9772aaddc8c6f2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using UnityEngine;
/// <summary>
/// Move each layer
/// Original script: https://pastebin.com/ZniykeGz.
/// YouTube link: https://youtu.be/MEy-kIGE-lI.
/// </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: aef6d1f03d04b16488ca52bf4c8231af
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: