rabidus-test/Assets/CurvedUI/Demo Scenes/Demo Scenes Content/CUI_inventory_paralax.cs

40 lines
1.2 KiB
C#
Raw Permalink Normal View History

2023-08-15 17:38:54 +03:00
using UnityEngine;
using System.Collections;
namespace CurvedUI
{
public class CUI_inventory_paralax : MonoBehaviour
{
#pragma warning disable 0649
[SerializeField]
Transform front;
[SerializeField]
Transform back;
#pragma warning restore 0649
Vector3 initFG;
Vector3 initBG;
public float change = 50;
// Use this for initialization
void Start()
{
initFG = front.position;
initBG = back.position;
}
// Update is called once per frame
void Update()
{
front.position = front.position.ModifyX(initFG.x + Input.mousePosition.x.Remap(0, Screen.width, -change, change));
back.position = back.position.ModifyX(initBG.x - Input.mousePosition.x.Remap(0, Screen.width, -change, change));
front.position = front.position.ModifyY(initFG.y + Input.mousePosition.y.Remap(0, Screen.height, -change, change) * (Screen.height / Screen.width));
back.position = back.position.ModifyY(initBG.y - Input.mousePosition.y.Remap(0, Screen.height, -change, change) * (Screen.height / Screen.width));
}
}
}