Files
VR-WuKong/Assets/GameRes/Main/SceneArt/VRScene/Scripts/Wethermain.cs

123 lines
2.6 KiB
C#
Raw Normal View History

2025-11-14 18:44:06 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Wethermain : MonoBehaviour
{
public Transform[] ts;
bool aaa;
bool bbb;
float time;
float timeB;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if(Input.GetKeyDown(KeyCode.Alpha1))
{
if(aaa)
{
aaa = false;
}
else
{
aaa = true;
}
}
if (Input.GetKeyDown(KeyCode.Alpha2))
{
if (bbb)
{
bbb = false;
}
else
{
bbb = true;
}
}
if (aaa)
{
time += Time.deltaTime * 2;
}
else
{
time -= Time.deltaTime * 2;
}
time = Mathf.Clamp(time, 0, 1);
asdasd(time);
//
if (bbb)
{
timeB += Time.deltaTime * 2;
}
else
{
timeB -= Time.deltaTime * 2;
}
timeB = Mathf.Clamp(timeB, 0, 1);
asdasdd(timeB);
}
void asdasd(float v)
{
foreach (Transform t in ts)
{
foreach (Transform tt in t.GetComponentsInChildren<Transform>())
{
if (tt.GetComponent<MeshRenderer>())
{
foreach (Material m in tt.GetComponent<MeshRenderer>().materials)
{
if (m.HasFloat("_Snownny"))
{
m.SetFloat("_Snownny", v);
}
}
}
//
if (tt.GetComponent<Grass>())
{
Material m = tt.GetComponent<Grass>().material;
m.SetFloat("_Snownny", v);
}
}
}
}
void asdasdd(float v)
{
foreach (Transform t in ts)
{
foreach (Transform tt in t.GetComponentsInChildren<Transform>())
{
if (tt.GetComponent<MeshRenderer>())
{
foreach (Material m in tt.GetComponent<MeshRenderer>().materials)
{
if (m.HasFloat("_Rainny"))
{
m.SetFloat("_Rainny", v);
}
}
}
}
}
}
}