(Mache nach 2-4h Schlaf weiter. Noch nicht ganz fertig, aufgrund aufgrund mangelnder Zeit durch Arbeit, damaligen privaten Problemen und damals zu viel vorgenommen).
35 lines
775 B
C#
35 lines
775 B
C#
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;
|
|
}
|
|
}
|
|
}
|