您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
31 行
816 B
31 行
816 B
using UnityEngine;
|
|
|
|
[ExecuteAlways]
|
|
public class WindzoneExtended : MonoBehaviour
|
|
{
|
|
public WindZone zone;
|
|
// vector for wind, x = radian, y = strength, z = turbulence, w = frequency
|
|
private Vector4 _windVector = Vector4.zero;
|
|
public string shaderProp = "_WindZone_Vector";
|
|
public float test;
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (!zone) return;
|
|
|
|
//Do Wind things
|
|
SetDirection();
|
|
|
|
Shader.SetGlobalVector(shaderProp, _windVector);
|
|
}
|
|
|
|
void SetDirection()
|
|
{
|
|
var vec = transform.forward;
|
|
vec.y = 0;
|
|
var sign = Vector3.Dot(Vector3.left, vec) < 0 ? -1f : 1f;
|
|
_windVector.x = (Vector3.Angle(Vector3.forward, vec) / 180f * Mathf.PI) * sign;
|
|
test = _windVector.x;
|
|
}
|
|
}
|