├── .gitignore ├── Assets ├── Plugins.meta ├── Plugins │ └── Editor.meta ├── Scene.meta ├── Scene │ ├── Main.unity │ ├── Main.unity.meta │ ├── TestRaycast.unity │ ├── TestRaycast.unity.meta │ ├── VertColor.unity │ └── VertColor.unity.meta ├── Scripts.meta └── Scripts │ ├── IgnoreRaycast.cs │ ├── IgnoreRaycast.cs.meta │ ├── RadarChart.cs │ ├── RadarChart.cs.meta │ ├── SubRadarChart.cs │ ├── SubRadarChart.cs.meta │ ├── Test.meta │ └── Test │ ├── Test.cs │ ├── Test.cs.meta │ ├── TestDebug.cs │ ├── TestDebug.cs.meta │ ├── TestInspector.cs │ ├── TestInspector.cs.meta │ ├── TestVertColor.cs │ └── TestVertColor.cs.meta ├── README.md ├── RadarMap.png └── UnityPackageManager └── manifest.json /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | /[Bb]uilds/ 6 | /Assets/AssetStoreTools* 7 | 8 | # Visual Studio 2015 cache directory 9 | /.vs/ 10 | 11 | # Autogenerated VS/MD/Consulo solution and project files 12 | ExportedObj/ 13 | .consulo/ 14 | *.csproj 15 | *.unityproj 16 | *.sln 17 | *.suo 18 | *.tmp 19 | *.user 20 | *.userprefs 21 | *.pidb 22 | *.booproj 23 | *.svd 24 | *.pdb 25 | 26 | # Unity3D generated meta files 27 | *.pidb.meta 28 | 29 | # Unity3D Generated File On Crash Reports 30 | sysinfo.txt 31 | 32 | # Builds 33 | *.apk 34 | *.unitypackage 35 | 36 | #other 37 | *.DS_Store 38 | /Assets/Plugins/Editor/JetBrains/ 39 | /Assets/Plugins/Editor/JetBrains.meta 40 | *.idea/ 41 | ProjectSettings/ 42 | -------------------------------------------------------------------------------- /Assets/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f669e0877698448acac6210342134748 3 | folderAsset: yes 4 | timeCreated: 1507898595 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Plugins/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1805824e1f1704c84bbbe1bde9246ec6 3 | folderAsset: yes 4 | timeCreated: 1507898595 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Scene.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76cf58076359347ce8d16534a8547875 3 | folderAsset: yes 4 | timeCreated: 1508055452 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Scene/Main.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zhuangdum/RadarChart/7ca1bf448ca4c26e81747d60594f498d6c7aeb8a/Assets/Scene/Main.unity -------------------------------------------------------------------------------- /Assets/Scene/Main.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e24e75fbe85d641ca9644ff15a1ee70b 3 | timeCreated: 1507898482 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scene/TestRaycast.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zhuangdum/RadarChart/7ca1bf448ca4c26e81747d60594f498d6c7aeb8a/Assets/Scene/TestRaycast.unity -------------------------------------------------------------------------------- /Assets/Scene/TestRaycast.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8ae208e2103e45b5839f97cd8c8ffba 3 | timeCreated: 1508055471 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scene/VertColor.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zhuangdum/RadarChart/7ca1bf448ca4c26e81747d60594f498d6c7aeb8a/Assets/Scene/VertColor.unity -------------------------------------------------------------------------------- /Assets/Scene/VertColor.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91ce0ab85411742bd84c5da1936318af 3 | timeCreated: 1509678887 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5833cab4fe24b4efe81277e01156d5ca 3 | folderAsset: yes 4 | timeCreated: 1507979065 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Scripts/IgnoreRaycast.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Text.RegularExpressions; 4 | using UnityEngine; 5 | using UnityEngine.UI; 6 | 7 | /// 8 | /// 可以让这个不可见的控件压根不参与绘制!让它彻底的消失,但是还能够阻挡后面ui的操作 9 | /// 10 | public class IgnoreRaycast : MaskableGraphic 11 | { 12 | protected IgnoreRaycast() 13 | { 14 | useLegacyMeshGeneration = false; 15 | } 16 | 17 | protected override void OnPopulateMesh(VertexHelper vh) 18 | { 19 | vh.Clear(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Assets/Scripts/IgnoreRaycast.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 70e2379833a5b4f47b9c1615824c07dc 3 | timeCreated: 1508055608 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/RadarChart.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | public enum ShadeType 7 | { 8 | Pentagon, //五边形 9 | Hexagon //六边形 10 | } 11 | 12 | /* 13 | 顶点位置示意图 14 | 15 | 2|7 16 | | 17 | | 18 | 3 | 6 19 | | 20 | | 21 | 0 1|4 5 22 | 23 | UV坐标示意图 24 | 25 | (0.0,1)-----------(1, 1) 26 | | | 27 | | | 28 | | | 29 | | | 30 | | | 31 | | | 32 | (0.0,0.0)---------(1.0,0.0) 33 | 34 | 三角形分布示意图 35 | 36 | x, w(1)-----------z, w(2) 37 | | | 38 | | | 39 | | | 40 | | | 41 | | | 42 | | | 43 | x, y(0)-----------z, y(3) 44 | 45 | 46 | 五边形顶点位置顺序示意图 47 | 48 | 3 49 | 50 | 51 | 4 2 52 | 53 | 54 | 55 | 0 1 56 | 57 | */ 58 | 59 | [RequireComponent(typeof(CanvasRenderer))] 60 | public class RadarChart : Graphic 61 | { 62 | private VertexHelper vertextHelper; 63 | 64 | //用于记录背景多边形的顶点数组位置 65 | private Vector2[] vertPos; 66 | 67 | //多边形边长 68 | public float edges = 100f; 69 | 70 | //多边形类型 71 | public ShadeType shadeType; 72 | 73 | //顶点文本 74 | public List vertText; 75 | 76 | //子多边形的顶点位置数据 77 | public List vertPosList; 78 | 79 | //重绘UI的Mesh 80 | protected override void OnPopulateMesh(VertexHelper vh) 81 | { 82 | if (shadeType == ShadeType.Pentagon) 83 | { 84 | DrawPentagon(vh); 85 | //设置每个顶点的文字说明 86 | if (vertText.Count >= 5) 87 | { 88 | vertText[0].rectTransform.anchoredPosition = vertPos[0]; 89 | vertText[1].rectTransform.anchoredPosition = vertPos[2]; 90 | vertText[2].rectTransform.anchoredPosition = vertPos[3]; 91 | vertText[3].rectTransform.anchoredPosition = vertPos[4]; 92 | vertText[4].rectTransform.anchoredPosition = vertPos[5]; 93 | } 94 | } 95 | else if(shadeType == ShadeType.Hexagon) 96 | { 97 | // TODO @zhuangduanming 98 | throw new NotImplementedException(); 99 | } 100 | } 101 | 102 | //重新绘制子雷达图 103 | public void RebuildSubRadar() 104 | { 105 | //绘制子雷达图的模样 106 | for (int i = 0; i < vertPosList.Count; i++) 107 | { 108 | //重新绘制子雷达图 109 | vertPosList[i].RebuildSubRadar(edges); 110 | } 111 | } 112 | 113 | //绘制五边形 114 | private void DrawPentagon(VertexHelper vh) 115 | { 116 | Rect pixelAdjustedRect = this.GetPixelAdjustedRect(); 117 | Color32 color = (Color32) this.color; 118 | vh.Clear(); 119 | Vector4 vector4 = new Vector4(pixelAdjustedRect.x, pixelAdjustedRect.y, pixelAdjustedRect.x + edges, 120 | pixelAdjustedRect.y + edges); 121 | Debug.Log("初始位置:x: " + vector4.x + " y:" + vector4.y + " height:" + pixelAdjustedRect.height + " width:" + 122 | pixelAdjustedRect.width); 123 | 124 | vertPos = new Vector2[6]; 125 | vertPos[0] = new Vector2(vector4.x, vector4.y); 126 | vertPos[1] = new Vector2(vector4.x + edges / 2, vector4.y); 127 | vertPos[2] = new Vector2(vector4.x + edges / 2, 128 | vector4.y + edges * (float) Math.Sin(Mathf.Deg2Rad * 72) + edges * (float) Math.Sin(Mathf.Deg2Rad * 36)); 129 | vertPos[3] = new Vector2(vector4.x - edges * (float) Math.Cos(Mathf.Deg2Rad * 72), 130 | vector4.y + edges * (float) Math.Sin(Mathf.Deg2Rad * 72)); 131 | vertPos[4] = new Vector2(vector4.x + edges, vector4.y); 132 | vertPos[5] = new Vector2(vector4.x + edges + edges * (float) Math.Cos(Mathf.Deg2Rad * 72), 133 | vector4.y + edges * (float) Math.Sin(Mathf.Deg2Rad * 72)); 134 | 135 | 136 | //顶点位置 137 | 138 | //添加左半边的四边形 139 | //0 140 | vh.AddVert(new Vector3(vertPos[0].x, vertPos[0].y), color, new Vector2(0.0f, 0.0f)); 141 | //1 142 | vh.AddVert(new Vector3(vertPos[1].x, vertPos[1].y), color, new Vector2(0.5f, 0.0f)); 143 | //2 144 | vh.AddVert(new Vector3(vertPos[2].x, vertPos[2].y), color, new Vector2(0.5f, 1f)); 145 | //3 146 | vh.AddVert(new Vector3(vertPos[3].x, vertPos[3].y), color, new Vector2(0.0f, 0.5f)); 147 | 148 | // //添加右半边的四边形 149 | //4 150 | vh.AddVert(new Vector3(vertPos[1].x, vertPos[1].y), color, new Vector2(0.5f, 0f)); 151 | //5 152 | vh.AddVert(new Vector3(vertPos[4].x, vertPos[4].y), color, new Vector2(1.0f, 0.0f)); 153 | //6 154 | vh.AddVert(new Vector3(vertPos[5].x, vertPos[5].y), color, new Vector2(1f, 0.5f)); 155 | //7 156 | vh.AddVert(new Vector3(vertPos[2].x, vertPos[2].y), color, new Vector2(0.5f, 1.0f)); 157 | 158 | 159 | //添加左半边的三角形 160 | vh.AddTriangle(0, 1, 2); 161 | vh.AddTriangle(2, 3, 0); 162 | 163 | // //添加右半边的三角形 164 | vh.AddTriangle(4, 5, 6); 165 | vh.AddTriangle(6, 7, 4); 166 | } 167 | } 168 | 169 | [Serializable] 170 | public class VertPosition 171 | { 172 | // 子雷达图的组件 173 | public SubRadarChart subRaderChart; 174 | //0 175 | [Range(0f, 1f)] 176 | [SerializeField] private float vert1; 177 | //1 178 | [Range(0f, 1f)] 179 | [SerializeField] private float vert2; 180 | //2 181 | [Range(0f, 1f)] 182 | [SerializeField] private float vert3; 183 | //3 184 | [Range(0f, 1f)] 185 | [SerializeField] private float vert4; 186 | //4 187 | [Range(0f, 1f)] 188 | [SerializeField] private float vert5; 189 | 190 | /* 191 | * 数组对应的顶点位置 192 | * 3 193 | * 194 | * 195 | * 4 2 196 | * 197 | * 198 | * 199 | * 0 1 200 | */ 201 | 202 | // 手动重绘子雷达图的图形 203 | public void RebuildSubRadar(float edges) 204 | { 205 | subRaderChart.SetRadarVertext(new []{vert1, vert2, vert3, vert4, vert5}, edges); 206 | subRaderChart.SetVerticesDirty(); 207 | } 208 | } -------------------------------------------------------------------------------- /Assets/Scripts/RadarChart.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 82139d644146d46d7952188f43361612 3 | timeCreated: 1507898626 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/SubRadarChart.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.UI; 4 | 5 | [RequireComponent(typeof(CanvasRenderer))] 6 | public class SubRadarChart : Graphic 7 | { 8 | // 多边形类型 9 | public ShadeType shadeType; 10 | 11 | private VertexHelper vertextHelper; 12 | 13 | [SerializeField] private Color bottomColor; 14 | 15 | [SerializeField] private Color topColor; 16 | 17 | // 用于记录背景多边形的顶点数组位置 18 | private Vector2[] vertPos = new Vector2[7]; 19 | 20 | // 用于记录多边形每个顶点的颜色 21 | private Color[] vertColor = new Color[6]; 22 | 23 | /*更加传入的顶点数据来绘制雷达图 24 | 顶点位置示意图 25 | 26 | 2 27 | | 28 | | 29 | 3 | 5 30 | 6 31 | | 32 | | 33 | | 34 | 0 1 4 35 | 36 | 37 | 38 | * 顶点颜色 39 | * 3 40 | * 41 | * 42 | * 43 | * 4 2 44 | * 45 | * 46 | * 47 | * 48 | * 49 | * 0 1 50 | * 51 | */ 52 | // 设置雷达图顶点信息 53 | public void SetRadarVertext(float[] vertArray, float edges) 54 | { 55 | if (vertArray.Length == 5) 56 | { 57 | float length = edges / 2 / Mathf.Cos(Mathf.Deg2Rad * 54); 58 | //计算各个顶点的位置 59 | Rect pixelAdjustedRect = this.GetPixelAdjustedRect(); 60 | Vector4 vector4 = new Vector4(pixelAdjustedRect.x, pixelAdjustedRect.y, pixelAdjustedRect.x + edges, 61 | pixelAdjustedRect.y + edges); 62 | 63 | //初始化顶点和颜色数组 64 | 65 | //计算顶点和颜色数组 66 | //0 67 | vertPos[0] = new Vector2(vector4.x + (1 - vertArray[0]) * edges / 2, 68 | vector4.y + Mathf.Tan(Mathf.Deg2Rad * 54) * (1 - vertArray[0]) * edges / 2); 69 | //1 70 | vertPos[1] = new Vector2(vector4.x + edges / 2, vector4.y); 71 | //2 72 | vertPos[2] = new Vector2(vector4.x + edges / 2, 73 | vector4.y + length * (Mathf.Sin(Mathf.Deg2Rad * 54) + vertArray[3])); 74 | //3 75 | vertPos[3] = new Vector2(vector4.x + edges / 2 - length * vertArray[4] * Mathf.Cos(Mathf.Deg2Rad * 18), 76 | vector4.y + length * Mathf.Sin(Mathf.Deg2Rad * 54) + 77 | length * Mathf.Sin(Mathf.Deg2Rad * 18) * vertArray[4]); 78 | //4 79 | vertPos[4] = new Vector2(vector4.x + edges / 2 * (1 + vertArray[1]), 80 | vector4.y + length * Mathf.Sin(Mathf.Deg2Rad * 54) * (1 - vertArray[1])); 81 | //5 82 | vertPos[5] = new Vector2(vector4.x + edges / 2 + length * vertArray[2] * Mathf.Cos(Mathf.Deg2Rad * 18), 83 | vector4.y + length * Mathf.Sin(Mathf.Deg2Rad * 54) + 84 | length * Mathf.Sin(Mathf.Deg2Rad * 18) * vertArray[2]); 85 | //6 86 | vertPos[6] = new Vector2(vector4.x + edges / 2, vector4.y + edges / 2 * Mathf.Tan(Mathf.Deg2Rad * 54)); 87 | 88 | 89 | vertColor[0] = Color.Lerp(bottomColor, topColor, 90 | Mathf.Sin(54 * Mathf.Deg2Rad) * (1 - vertArray[0]) / (Mathf.Sin(54 * Mathf.Deg2Rad) + 1)); 91 | vertColor[1] = Color.Lerp(bottomColor, topColor, 92 | Mathf.Sin(54 * Mathf.Deg2Rad) * (1 - vertArray[1]) / (Mathf.Sin(54 * Mathf.Deg2Rad) + 1)); 93 | vertColor[2] = Color.Lerp(bottomColor, topColor, 94 | (Mathf.Sin(54 * Mathf.Deg2Rad) + vertArray[2] * Mathf.Cos(72 * Mathf.Deg2Rad)) / 95 | (Mathf.Sin(54 * Mathf.Deg2Rad) + 1)); 96 | vertColor[3] = Color.Lerp(bottomColor, topColor, 97 | (Mathf.Sin(54 * Mathf.Deg2Rad) + vertArray[3]) / (Mathf.Sin(54 * Mathf.Deg2Rad) + 1)); 98 | vertColor[4] = Color.Lerp(bottomColor, topColor, 99 | (Mathf.Sin(54 * Mathf.Deg2Rad) + vertArray[4] * Mathf.Cos(72 * Mathf.Deg2Rad)) / 100 | (Mathf.Sin(54 * Mathf.Deg2Rad) + 1)); 101 | vertColor[5] = Color.Lerp(bottomColor, topColor, 102 | Mathf.Sin(54 * Mathf.Deg2Rad) / (Mathf.Sin(54 * Mathf.Deg2Rad) + 1)); 103 | } 104 | else 105 | { 106 | //TODO 传入的数据没有按照格式传递 107 | throw new FormatException(); 108 | } 109 | } 110 | 111 | // 重绘UI的Mesh 112 | protected override void OnPopulateMesh(VertexHelper vh) 113 | { 114 | if (shadeType == ShadeType.Pentagon) 115 | { 116 | DrawPentagon(vh); 117 | Debug.Log("重绘制子雷达图"); 118 | } 119 | } 120 | 121 | /*通过中心点绘制五边形 122 | * 顶点位置示意图 123 | * 3 124 | * 125 | * 126 | * 127 | * 4 2 128 | * 5 129 | * 130 | * 131 | * 132 | * 133 | * 0 1 134 | * 135 | */ 136 | 137 | // 填充五边形的绘制信息到UGUI内置的数据结构里 138 | private void DrawPentagon(VertexHelper vh) 139 | { 140 | Color32 color = (Color32) this.color; 141 | vh.Clear(); 142 | //添加左半边的四边形 143 | //0 144 | vh.AddVert(new Vector3(vertPos[0].x, vertPos[0].y), vertColor[0], new Vector2(0.0f, 0.0f)); 145 | //1 146 | vh.AddVert(new Vector3(vertPos[4].x, vertPos[4].y), vertColor[1], new Vector2(1.0f, 0.0f)); 147 | //2 148 | vh.AddVert(new Vector3(vertPos[5].x, vertPos[5].y), vertColor[2], new Vector2(1f, 0.5f)); 149 | //3 150 | vh.AddVert(new Vector3(vertPos[2].x, vertPos[2].y), vertColor[3], new Vector2(0.5f, 1f)); 151 | //4 152 | vh.AddVert(new Vector3(vertPos[3].x, vertPos[3].y), vertColor[4], new Vector2(0.0f, 0.5f)); 153 | //5 154 | vh.AddVert(new Vector3(vertPos[6].x, vertPos[6].y), vertColor[5], new Vector2(0.0f, 0.5f)); 155 | 156 | //添加左半边的三角形 157 | vh.AddTriangle(0, 1, 5); 158 | vh.AddTriangle(5, 1, 2); 159 | vh.AddTriangle(5, 2, 3); 160 | vh.AddTriangle(5, 3, 4); 161 | vh.AddTriangle(5, 4, 0); 162 | } 163 | } -------------------------------------------------------------------------------- /Assets/Scripts/SubRadarChart.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e7b45785502054457bb5a02701b65476 3 | timeCreated: 1507979081 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/Test.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e49f9f57b09094912aa69def6c87a342 3 | folderAsset: yes 4 | timeCreated: 1508055431 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Scripts/Test/Test.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class Test : MonoBehaviour 6 | { 7 | public RadarChart radarChart; 8 | public void UpdateCanvas() 9 | { 10 | radarChart.rectTransform.sizeDelta = new Vector2(100, 130); 11 | } 12 | 13 | public void UpdateColor() 14 | { 15 | radarChart.SetVerticesDirty(); 16 | } 17 | 18 | public void UpdateVertices() 19 | { 20 | radarChart.RebuildSubRadar(); 21 | } 22 | 23 | public void TestClick() 24 | { 25 | Debug.Log("you have click the button"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Assets/Scripts/Test/Test.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 867021f0fc9cf403eb5d909e13c0cae8 3 | timeCreated: 1507980685 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/Test/TestDebug.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class TestDebug : MonoBehaviour 6 | { 7 | private void Update() 8 | { 9 | 10 | } 11 | 12 | private void OnGUI() 13 | { 14 | if(GUI.Button(new Rect(0, 100, 100, 100),"log")) 15 | { 16 | Debug.Log("debug"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Assets/Scripts/Test/TestDebug.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f002c8e783244abdb922621456a741c 3 | timeCreated: 1509613913 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/Test/TestInspector.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using UnityEngine.UI; 4 | 5 | [CustomEditor(typeof(RadarChart))] 6 | public class TestInspector : Editor 7 | { 8 | public override void OnInspectorGUI() 9 | { 10 | DrawDefaultInspector(); 11 | 12 | RadarChart myScript = (RadarChart)target; 13 | if(GUILayout.Button("PopulateMesh")) 14 | { 15 | Debug.Log("test inspector GUI"); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Assets/Scripts/Test/TestInspector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f7b3bc51031644e6e874bba8dad245f7 3 | timeCreated: 1507980260 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/Test/TestVertColor.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | /* 7 | (0, 1) (1, 1) 8 | 9 | 10 | 11 | 12 | 13 | (0, 0) (1, 0) 14 | */ 15 | 16 | public class TestVertColor : Graphic 17 | { 18 | public Color startColor; 19 | public Color endColor; 20 | 21 | protected override void OnPopulateMesh(VertexHelper vh) 22 | { 23 | Rect pixelAdjustedRect = this.GetPixelAdjustedRect(); 24 | Vector4 vector4 = new Vector4(pixelAdjustedRect.x, pixelAdjustedRect.y, pixelAdjustedRect.x + pixelAdjustedRect.width, pixelAdjustedRect.y + pixelAdjustedRect.height); 25 | // Color32 color = (Color32) this.color; 26 | vh.Clear(); 27 | vh.AddVert(new Vector3(vector4.x, vector4.y), startColor, new Vector2(0.0f, 0.0f)); 28 | vh.AddVert(new Vector3(vector4.x, vector4.w), endColor, new Vector2(0.0f, 1f)); 29 | vh.AddVert(new Vector3(vector4.z, vector4.w), endColor, new Vector2(1f, 1f)); 30 | vh.AddVert(new Vector3(vector4.z, vector4.y), startColor, new Vector2(1f, 0.0f)); 31 | vh.AddTriangle(0, 1, 2); 32 | vh.AddTriangle(2, 3, 0); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Assets/Scripts/Test/TestVertColor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e10413a3c2c24a8bb172a829ddb3520 3 | timeCreated: 1509678909 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RadarChart 2 | 3 | - change the vertices by redefine the parameter in scripts RadarMap 4 | - call the function RebuildSubradar to rebuild the radar 5 | 6 | ![image](https://github.com/Zhuangdum/RadarMap/blob/master/RadarMap.png) 7 | 8 | - add subradar color lerp from bottom to top function //date: 2017.11.07 9 | 10 | - 2018.03.16 unity 2017.3.0f3 version 11 | -------------------------------------------------------------------------------- /RadarMap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zhuangdum/RadarChart/7ca1bf448ca4c26e81747d60594f498d6c7aeb8a/RadarMap.png -------------------------------------------------------------------------------- /UnityPackageManager/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | } 4 | } 5 | --------------------------------------------------------------------------------