53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
using System.Linq;
|
|
using System.Collections;
|
|
using System.Threading.Tasks;
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
public class SceneHandler : MonoBehaviour
|
|
{
|
|
[SerializeField] Material skyboxMaterial;
|
|
|
|
async Task Start()
|
|
{
|
|
var skyboxExposure = 1;
|
|
float currentExposure = 0;
|
|
skyboxMaterial.SetFloat("_Exposure", 0);
|
|
|
|
float startPositionValue = -18;
|
|
float currentPositionValue = startPositionValue;
|
|
float endPositionValue = 3;
|
|
|
|
var objectsWithEffect = FindObjectsOfType<MeshRenderer>()
|
|
.Where(x => x.sharedMaterial.shader.name.Contains("S_Holographic"))
|
|
.ToList();
|
|
|
|
foreach(var item in objectsWithEffect)
|
|
item.sharedMaterial.SetFloat("_EffectPosition", startPositionValue);
|
|
|
|
while(currentPositionValue != endPositionValue)
|
|
{
|
|
currentPositionValue = Mathf.MoveTowards(currentPositionValue,
|
|
endPositionValue,
|
|
Time.deltaTime * 3);
|
|
|
|
Debug.Log(currentPositionValue);
|
|
|
|
foreach(var item in objectsWithEffect)
|
|
item.material.SetFloat("_EffectPosition",
|
|
currentPositionValue);
|
|
|
|
await Task.Yield();
|
|
}
|
|
|
|
while(currentExposure != skyboxExposure)
|
|
{
|
|
currentExposure = Mathf.MoveTowards(currentExposure, skyboxExposure, Time.deltaTime);
|
|
skyboxMaterial.SetFloat("_Exposure", currentExposure);
|
|
|
|
await Task.Yield();
|
|
}
|
|
}
|
|
}
|