ProjectDDD/Assets/0.Datas/02.Scripts/GenerateGoogleSheet/Core/GoogleSheetDiffViewer.cs

69 lines
2.5 KiB (Stored with Git LFS)
C#

#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using System.Collections.Generic;
public class GoogleSheetDiffViewer : EditorWindow
{
private List<GoogleSheetDiff> _diffs;
private bool _isReversed; // true: 현재 → 선택버전, false: 변경 전 → 변경 후
private Vector2 _scroll;
public static void ShowWindow(List<GoogleSheetDiff> diffs, bool isReversed = false)
{
var window = GetWindow<GoogleSheetDiffViewer>("Google Sheet 변경점");
window._diffs = diffs;
window._isReversed = isReversed;
window.Show();
}
private void OnGUI()
{
EditorGUILayout.LabelField("변경된 항목", EditorStyles.boldLabel);
EditorGUILayout.Space();
if (_diffs == null || _diffs.Count == 0)
{
EditorGUILayout.HelpBox("변경 사항이 없습니다.", MessageType.Info);
return;
}
// 헤더
EditorGUILayout.BeginHorizontal("box");
EditorGUILayout.LabelField("시트", EditorStyles.boldLabel, GUILayout.Width(80));
EditorGUILayout.LabelField("행", EditorStyles.boldLabel, GUILayout.Width(40));
EditorGUILayout.LabelField("필드", EditorStyles.boldLabel, GUILayout.Width(100));
GUIStyle oldStyle = new GUIStyle(EditorStyles.label);
oldStyle.normal.textColor = Color.green;
EditorGUILayout.LabelField(_isReversed ? "현재 버전" : "변경 전", oldStyle, GUILayout.Width(100));
GUIStyle newStyle = new GUIStyle(EditorStyles.label);
newStyle.normal.textColor = new Color(0.3f, 0.75f, 1.0f);
EditorGUILayout.LabelField(_isReversed ? "선택한 버전" : "변경 후", newStyle, GUILayout.Width(100));
EditorGUILayout.EndHorizontal();
_scroll = EditorGUILayout.BeginScrollView(_scroll);
foreach (var diff in _diffs)
{
EditorGUILayout.BeginHorizontal("box");
EditorGUILayout.LabelField(diff.Sheet, GUILayout.Width(80));
EditorGUILayout.LabelField(diff.RowIndex.ToString(), GUILayout.Width(40));
EditorGUILayout.LabelField(diff.Field, GUILayout.Width(100));
string left = _isReversed ? diff.NewValue : diff.OldValue;
string right = _isReversed ? diff.OldValue : diff.NewValue;
EditorGUILayout.LabelField(left, oldStyle, GUILayout.Width(100));
EditorGUILayout.LabelField(right, newStyle, GUILayout.Width(100));
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.EndScrollView();
}
}
#endif