Flatkit 추가 및 설정
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class BillboardLineRendererCircle : MonoBehaviour {
|
||||
public Color color = Color.black;
|
||||
public float width = 1f;
|
||||
public int numSegments = 50;
|
||||
public float radius = 0.5f;
|
||||
|
||||
private LineRenderer _lineRenderer;
|
||||
|
||||
void Start() {
|
||||
_lineRenderer = gameObject.GetComponent<LineRenderer>();
|
||||
if (_lineRenderer != null) return;
|
||||
|
||||
// Initialize line renderer.
|
||||
_lineRenderer = gameObject.AddComponent<LineRenderer>();
|
||||
_lineRenderer.materials = new[] {
|
||||
new Material(Shader.Find("Universal Render Pipeline/Unlit")) { color = color }
|
||||
};
|
||||
_lineRenderer.startWidth = width * 0.01f;
|
||||
_lineRenderer.endWidth = width * 0.01f;
|
||||
_lineRenderer.positionCount = numSegments + 1;
|
||||
_lineRenderer.useWorldSpace = false;
|
||||
|
||||
// Create points.
|
||||
float deltaTheta = (float)(2.0 * Mathf.PI) / numSegments;
|
||||
float theta = 0f;
|
||||
|
||||
for (int i = 0; i < numSegments + 1; i++) {
|
||||
float x = Mathf.Cos(theta);
|
||||
float y = Mathf.Sin(theta);
|
||||
Vector3 pos = new Vector3(x, y, 0);
|
||||
_lineRenderer.SetPosition(i, pos * radius);
|
||||
theta += deltaTheta;
|
||||
}
|
||||
}
|
||||
|
||||
[ContextMenu("Reinitialize")]
|
||||
private void Reinitialize() {
|
||||
if (_lineRenderer != null) {
|
||||
DestroyImmediate(_lineRenderer);
|
||||
}
|
||||
|
||||
Start();
|
||||
Update();
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
transform.LookAt(Camera.main.transform);
|
||||
transform.Rotate(0, 180, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5a84995609d4fa40a2186a966b314d6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
56
Assets/FlatKit/Demos/[Demo] Desert/Scripts/FloatingMotion.cs
Normal file
56
Assets/FlatKit/Demos/[Demo] Desert/Scripts/FloatingMotion.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace Dustyroom {
|
||||
public class FloatingMotion : MonoBehaviour {
|
||||
public float verticalAmplitude = 1.0f;
|
||||
public float horizontalAmplitude = 0.0f;
|
||||
public bool startAtRandomOffset = true;
|
||||
|
||||
[Space]
|
||||
public float speed = 1.0f;
|
||||
|
||||
[Space, Tooltip("In seconds")]
|
||||
public float startDelay = 0;
|
||||
|
||||
[Space]
|
||||
public bool worldSpace = false;
|
||||
|
||||
private Vector3 _initialPosition;
|
||||
private float _offsetH = 0f;
|
||||
private float _offsetV = 0f;
|
||||
private bool _isMoving = false;
|
||||
|
||||
private void Start() {
|
||||
Invoke(nameof(Initialize), startDelay);
|
||||
}
|
||||
|
||||
private void Initialize() {
|
||||
_initialPosition = worldSpace ? transform.position : transform.localPosition;
|
||||
|
||||
if (startAtRandomOffset) {
|
||||
_offsetH = Random.value * 1000f;
|
||||
_offsetV = Random.value * 1000f;
|
||||
}
|
||||
|
||||
_isMoving = true;
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
if (!_isMoving) {
|
||||
return;
|
||||
}
|
||||
|
||||
var hDirection = new Vector3(Mathf.Sin(Time.timeSinceLevelLoad * speed * 0.5f + _offsetV + 100f), 0f,
|
||||
Mathf.Cos(Time.timeSinceLevelLoad * speed + _offsetV + 100f));
|
||||
Vector3 offset = Vector3.up * (Mathf.Sin(Time.timeSinceLevelLoad * speed + _offsetH) * verticalAmplitude) +
|
||||
hDirection * (Mathf.Sin(Time.timeSinceLevelLoad * speed + _offsetV) * horizontalAmplitude);
|
||||
Vector3 position = _initialPosition + offset * Time.timeScale;
|
||||
if (worldSpace) {
|
||||
transform.position = position;
|
||||
} else {
|
||||
transform.localPosition = position;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c46c900fc2e9cb40a4250810d5e07a4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user