This commit is contained in:
2021-01-29 19:11:05 +08:00
commit 46ba6614f9
45 changed files with 3296 additions and 0 deletions

41
Assets/Script/Graph.cs Normal file
View File

@ -0,0 +1,41 @@
using UnityEngine;
public class Graph : MonoBehaviour
{
[SerializeField]
Transform pointPrefab = default;
[SerializeField, Range(10, 100)]
int resolution = 10;
Transform[] points;
private void Awake()
{
var step = 2.0f / resolution;
var position = Vector3.zero;
var scale = Vector3.one * step;
points = new Transform[resolution];
for (int i = 0; i < points.Length; i++)
{
Transform point = Instantiate(pointPrefab);
position.x = (i + 0.5f) * step - 1.0f;
point.localPosition = position;
point.localScale = scale;
point.SetParent(transform, false);
points[i] = point;
}
}
private void Update()
{
var time = Time.time;
for (int i = 0; i < points.Length; i++)
{
Transform point = points[i];
Vector3 position = point.localPosition;
position.y = Mathf.Sin(Mathf.PI * (position.x + time));
point.localPosition = position;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 14cd06bfa92d53e4ebc0cde4a0e39db8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: