62 lines
1.8 KiB
C#
62 lines
1.8 KiB
C#
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEditor;
|
|||
|
|
|
|||
|
|
[CustomEditor(typeof(GeoDataContainer))]
|
|||
|
|
public class GeoDataViewer : Editor
|
|||
|
|
{
|
|||
|
|
private Dictionary<string, List<Coords>> geoDataDictionary;
|
|||
|
|
|
|||
|
|
public override void OnInspectorGUI()
|
|||
|
|
{
|
|||
|
|
base.OnInspectorGUI();
|
|||
|
|
|
|||
|
|
GeoDataContainer dataAsset = (GeoDataContainer)target;
|
|||
|
|
|
|||
|
|
if (dataAsset.geoDatas == null)
|
|||
|
|
{
|
|||
|
|
EditorGUILayout.HelpBox("GeoDatas <20>б<EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>", MessageType.Warning);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (GUILayout.Button("ˢ<>²<EFBFBD><C2B2><EFBFBD><EFBFBD><EFBFBD> Dictionary"))
|
|||
|
|
{
|
|||
|
|
BuildDictionary(dataAsset.geoDatas);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (geoDataDictionary != null)
|
|||
|
|
{
|
|||
|
|
EditorGUILayout.Space();
|
|||
|
|
EditorGUILayout.LabelField("Dictionary Ԥ<><D4A4>", EditorStyles.boldLabel);
|
|||
|
|
foreach (var kvp in geoDataDictionary)
|
|||
|
|
{
|
|||
|
|
EditorGUILayout.BeginVertical("box");
|
|||
|
|
EditorGUILayout.LabelField($"Key: {kvp.Key} <20><>{kvp.Value.Count} Groups<70><73>");
|
|||
|
|
EditorGUI.indentLevel++;
|
|||
|
|
foreach (var coords in kvp.Value)
|
|||
|
|
{
|
|||
|
|
EditorGUILayout.LabelField($"Coords Group: {coords.coords.Count} Points");
|
|||
|
|
}
|
|||
|
|
EditorGUI.indentLevel--;
|
|||
|
|
EditorGUILayout.EndVertical();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BuildDictionary(List<GeoData> geoDatas)
|
|||
|
|
{
|
|||
|
|
geoDataDictionary = new Dictionary<string, List<Coords>>();
|
|||
|
|
|
|||
|
|
foreach (var geoData in geoDatas)
|
|||
|
|
{
|
|||
|
|
if (!geoDataDictionary.ContainsKey(geoData.key))
|
|||
|
|
{
|
|||
|
|
geoDataDictionary.Add(geoData.key, geoData.values);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Debug.LogWarning($"<22>ظ<EFBFBD><D8B8><EFBFBD> Key<65><79>{geoData.key}<7D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|