You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
3.5 KiB

using System;
using UnityEngine;
namespace FX
{
// Token: 0x02000766 RID: 1894
[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
public class FX_Polygon_Flag : MonoBehaviour
{
// Token: 0x06003054 RID: 12372 RVA: 0x001038F8 File Offset: 0x001038F8
private void Start()
{
this._renderer = base.GetComponent<Renderer>();
this._meshFilter = base.GetComponent<MeshFilter>();
this._mesh = new Mesh();
this._mesh.vertices = this._vertices;
this._mesh.uv = this._uv;
this._prevPosition = base.transform.position;
}
// Token: 0x06003055 RID: 12373 RVA: 0x0010395C File Offset: 0x0010395C
private void Update()
{
if (this._renderer != null && this._renderer.material != null)
{
Vector3 a = this._prevPosition + this._nowChaser;
this._nowChaser = Vector3.Lerp(a, base.transform.position, this._tailDamper) - base.transform.position;
this._nowChaser_Rot = Quaternion.Lerp(this._nowChaser_Rot, base.transform.parent.rotation, this._tailDamper);
this._vertices[1] = base.transform.parent.rotation * this._topPosition;
this._vertices[2] = this._nowChaser;
this._vertices[3] = this._nowChaser + this._nowChaser_Rot * this._topPosition;
float num = Vector3.Distance(Vector3.zero, this._nowChaser);
float num2 = Vector3.Distance(this._vertices[1], this._vertices[3]);
float num3 = (num <= num2) ? num2 : num;
float a2 = Mathf.Clamp01((num3 - this._minLength) / this._visibleLength);
this._colors[0].a = a2;
this._colors[1].a = a2;
this._colors[2].a = a2;
this._colors[3].a = a2;
if (num3 > this._minLength)
{
this._mesh.vertices = this._vertices;
this._mesh.colors = this._colors;
this._mesh.triangles = this._triangles;
this._meshFilter.sharedMesh = this._mesh;
}
else
{
this._meshFilter.sharedMesh = null;
}
this._prevPosition = base.transform.position;
base.transform.rotation = Quaternion.identity;
}
}
// Token: 0x04005698 RID: 22168
[SerializeField]
[Range(0f, 1f)]
[Tooltip("この値が高い程 短くなります")]
private float _tailDamper = 0.2f;
// Token: 0x04005699 RID: 22169
[Tooltip("先端の位置(相対)")]
[SerializeField]
private Vector3 _topPosition = new Vector3(0f, 0f, 0.6f);
// Token: 0x0400569A RID: 22170
[Tooltip("描画される最短距離")]
[SerializeField]
private float _minLength = 0.2f;
// Token: 0x0400569B RID: 22171
[SerializeField]
[Tooltip("minLengthから頂点アルファが1になるまでの距離初期値固定")]
private float _visibleLength = 0.3f;
// Token: 0x0400569C RID: 22172
private Renderer _renderer;
// Token: 0x0400569D RID: 22173
private Vector3 _nowChaser;
// Token: 0x0400569E RID: 22174
private Vector3 _prevPosition;
// Token: 0x0400569F RID: 22175
private Quaternion _nowChaser_Rot;
// Token: 0x040056A0 RID: 22176
private Mesh _mesh;
// Token: 0x040056A1 RID: 22177
private int[] _triangles = new int[]
{
0,
1,
2,
2,
1,
3
};
// Token: 0x040056A2 RID: 22178
private Vector2[] _uv = new Vector2[]
{
Vector2.zero,
Vector2.up,
Vector2.right,
Vector2.one
};
// Token: 0x040056A3 RID: 22179
private Color[] _colors = new Color[]
{
Color.white,
Color.white,
Color.white,
Color.white
};
// Token: 0x040056A4 RID: 22180
private Vector3[] _vertices = new Vector3[]
{
Vector3.zero,
Vector3.zero,
Vector3.zero,
Vector3.zero
};
// Token: 0x040056A5 RID: 22181
private MeshFilter _meshFilter;
}
}