This repository has been archived on 2025-04-28. You can view files and clone it, but cannot push or open issues or pull requests.
ARPlusSystem/ARPlusSystem-250418/Assets/Editor/GeoDataViewer.cs

62 lines
1.8 KiB
C#
Raw Permalink Normal View History

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>");
}
}
}
}