9using System.Collections.Generic;
16 #pragma warning disable 0649
18 private AnimationCurve _motionCurve;
19 #pragma warning restore 0649
22 private Gradient _gradient =
null;
24 private List<LeapGraphic> _graphics =
new List<LeapGraphic>();
25 private List<Vector3> _originalPositions =
new List<Vector3>();
26 private List<LeapBlendShapeData> _blendShapeData =
new List<LeapBlendShapeData>();
27 private List<LeapRuntimeTintData> _tintData =
new List<LeapRuntimeTintData>();
29 private void Start() {
30 _graphics.AddRange(GetComponentsInChildren<LeapGraphic>());
31 _graphics.Query().Select(g => g.transform.localPosition).FillList(_originalPositions);
32 _graphics.Query().Select(g => g.GetFeatureData<
LeapBlendShapeData>()).FillList(_blendShapeData);
36 private void Update() {
37 float fade = Mathf.Clamp01(Time.time * 0.5f - 0.5f);
39 for (
int i = 0; i < _graphics.Count; i++) {
40 _graphics[i].transform.localPosition = _originalPositions[i];
42 float a = fade * 10 * noise(_graphics[i].transform.position, 42.0f, 0.8f);
43 float b = noise(_graphics[i].transform.position * 1.7f, 23, 0.35f);
44 float c = fade * _motionCurve.Evaluate(b);
45 float d = fade * (c * 0.1f + a * (c * 0.03f + 0.01f) + _graphics[i].transform.position.z * 0.14f);
47 _blendShapeData[i].amount = c;
48 _graphics[i].transform.localPosition += Vector3.up * d;
49 _tintData[i].color = fade * _gradient.Evaluate(b);
53 private float noise(Vector3 offset,
float seed,
float speed) {
54 float x1 = seed * 23.1239879f;
55 float y1 = seed * 82.1239812f;
61 float x2 = seed * 23.1239879f;
62 float y2 = seed * 82.1239812f;
68 return Mathf.PerlinNoise(offset.x + x1 + Time.time * speed, offset.z + y1 + Time.time * speed) * 0.5f +
69 Mathf.PerlinNoise(offset.x + x2 - Time.time * speed, offset.z + y2 - Time.time * speed) * 0.5f;