mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-13 11:47:40 +02:00
Built to Scale (DS) asset setup
This commit is contained in:
55
Assets/Scripts/Games/BuiltToScaleDS/BuiltToScaleDS.cs
Normal file
55
Assets/Scripts/Games/BuiltToScaleDS/BuiltToScaleDS.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using NaughtyBezierCurves;
|
||||
using DG.Tweening;
|
||||
|
||||
using RhythmHeavenMania.Util;
|
||||
namespace RhythmHeavenMania.Games.BuiltToScaleDS
|
||||
{
|
||||
public class BuiltToScaleDS : Minigame
|
||||
{
|
||||
[Header("Camera")]
|
||||
public Transform renderQuadTrans;
|
||||
public Transform cameraPos;
|
||||
|
||||
[Header("References")]
|
||||
public SkinnedMeshRenderer environmentRenderer;
|
||||
|
||||
[Header("Properties")]
|
||||
public float beltSpeed = 1f;
|
||||
|
||||
private Material beltMaterial;
|
||||
private Material[] environmentMaterials;
|
||||
private float currentBeltOffset;
|
||||
|
||||
public static BuiltToScaleDS instance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
|
||||
environmentMaterials = environmentRenderer.materials;
|
||||
beltMaterial = Instantiate(environmentMaterials[8]);
|
||||
environmentMaterials[8] = beltMaterial;
|
||||
}
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
renderQuadTrans.gameObject.SetActive(true);
|
||||
|
||||
var cam = GameCamera.instance.camera;
|
||||
var camHeight = 2f * cam.orthographicSize;
|
||||
var camWidth = camHeight * cam.aspect;
|
||||
renderQuadTrans.localScale = new Vector3(camWidth, camHeight, 1f);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
currentBeltOffset = (currentBeltOffset + Time.deltaTime * -beltSpeed) % 1f;
|
||||
beltMaterial.mainTextureOffset = new Vector2(0f, currentBeltOffset);
|
||||
environmentRenderer.materials = environmentMaterials;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user