This repository has been archived by the owner on Feb 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SceneAnimator.cs
52 lines (45 loc) · 1.52 KB
/
SceneAnimator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SceneAnimator : MonoBehaviour
{
public GameObject layer0, layer1, layer2, layer3, canvas;
public float scalingFactor = 0.1f;
float scale;
Vector3 oldMousePos;
Vector3 posOldRelative;
Vector3 l0, l1, l2, l3, mouse, can;
public float layerOneOffset_Y;
void Start()
{
can = canvas.transform.position;
l0 = layer0.transform.position + can;
l1 = layer1.transform.position + can;
l2 = layer2.transform.position + can;
l3 = layer3.transform.position + can;
}
void FixedUpdate()
{
mouse = Input.mousePosition;
if (!(mouse.x <= 0 || mouse.x > Screen.width - 1))
{
mouse.x -= Screen.width / 2;
l0.x = (mouse.x * scalingFactor * 8);
l1.x = (mouse.x * scalingFactor * 4);
l2.x = (mouse.x * scalingFactor * 2);
l3.x = (mouse.x * scalingFactor * 1);
}
if (!(mouse.y <= 0 || mouse.x > Screen.height - 1))
{
mouse.y -= Screen.height / 2;
l0.y = (mouse.y * scalingFactor * 8);
l1.y = (mouse.y * scalingFactor * 4) + layerOneOffset_Y;
l2.y = (mouse.y * scalingFactor * 2);
l3.y = (mouse.y * scalingFactor * 1);
}
layer0.transform.position = l0 + can;
layer1.transform.position = l1 + can;
layer2.transform.position = l2 + can;
layer3.transform.position = l3 + can;
}
}