Roman ccdd7a0d68 1.优化项目结构
2.删除没用的场景
3.将各种系统都保存为预制体
4.分好了场景内的游戏物体分级
2021-07-24 23:57:48 +08:00

29 lines
829 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/*
更新日期2021.7.24 视差类
使用方式将类挂载到需要视差的背景上将主摄像机赋值给Cam调节视差率即可
注意 移动的背景一定要比不移动的面积大
*/
public class Parallax : MonoBehaviour
{
public Transform Cam;//视差摄像机
public float moveRate;//视差率
private float startPoint;//起点,自动获取
// Start is called before the first frame update
void Start()
{
startPoint = transform.position.x;//获取当前起点位置
}
// Update is called once per frame
void Update()
{
//每帧更新位置
transform.position = new Vector2(startPoint + Cam.position.x * moveRate, transform.position.y);
}
}