73 lines
2.0 KiB
C#
73 lines
2.0 KiB
C#
/*
|
|
* @Author: huosk
|
|
* @Date: 2019-12-30 10:58:46
|
|
* @Last Modified by: huosk
|
|
* @Last Modified time: 2019-12-30 11:48:38
|
|
*/
|
|
|
|
using UnityEngine;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
public class TestHeatMap : MonoBehaviour
|
|
{
|
|
|
|
public int count = 50;
|
|
public List<HeatPoint> heatPoints;
|
|
public Heatmap heatmap;
|
|
public Transform[] m_Transforms;
|
|
public Vector3[] m_Vector3s;
|
|
public Vector2[] m_Vector2s;
|
|
void Start()
|
|
{
|
|
//heatPoints.Clear();
|
|
|
|
//for ( int i = 0 ; i < count ; i++ )
|
|
//{
|
|
// heatPoints.Add(new HeatPoint()
|
|
// {
|
|
// point = new Vector3(Random.Range(-10f, 10f), 0.1f, Random.Range(-10f, 10f)),
|
|
// radius = Random.Range(0.2f, 0.5f),
|
|
// intensity = Random.Range(0.25f, 1)
|
|
// });
|
|
// heatmap.AddHeatPoint(heatPoints[i].point, heatPoints[i].radius, heatPoints[i].intensity);
|
|
//}
|
|
|
|
heatPoints.Clear();
|
|
|
|
for (int i = 0; i < m_Transforms.Length; i++)
|
|
{
|
|
heatPoints.Add(new HeatPoint()
|
|
{
|
|
point = m_Transforms[i].position,
|
|
radius = m_Vector2s[i].x,
|
|
intensity = m_Vector2s[i].y
|
|
});
|
|
heatmap.AddHeatPoint(heatPoints[i].point, heatPoints[i].radius, heatPoints[i].intensity);
|
|
}
|
|
|
|
//heatPoints.Clear();
|
|
|
|
//for (int i = 0; i < m_Vector3s.Length; i++)
|
|
//{
|
|
// heatPoints.Add(new HeatPoint()
|
|
// {
|
|
// point = m_Vector3s[i],
|
|
// radius = Random.Range(1f, 1f),
|
|
// intensity = Random.Range(1f, 1)
|
|
// });
|
|
// heatmap.AddHeatPoint(heatPoints[i].point, heatPoints[i].radius, heatPoints[i].intensity);
|
|
//}
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
heatmap.SetHeatPoints(heatPoints.Select((v) => new HeatPoint()
|
|
{
|
|
//point = transform.TransformPoint(v.point),
|
|
point = v.point,
|
|
radius = v.radius,
|
|
intensity = v.intensity
|
|
}));
|
|
}
|
|
} |