first
This commit is contained in:
58
Assets/02_Scripts/Story/Editor/StoryBeatDrawer.cs
Normal file
58
Assets/02_Scripts/Story/Editor/StoryBeatDrawer.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
// StoryBeat를 리스트에서 접었을 때 "Element N" 대신 요약 제목을 보여준다.
|
||||
// Note가 있으면 Note 우선, 없으면 "[진행도] 장소 · 캐릭터 · 대화"를 자동 조합.
|
||||
[CustomPropertyDrawer(typeof(StoryBeat))]
|
||||
public class StoryBeatDrawer : PropertyDrawer
|
||||
{
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
=> EditorGUI.GetPropertyHeight(property, label, includeChildren: true);
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
string summary = BuildSummary(property);
|
||||
if (!string.IsNullOrEmpty(summary))
|
||||
label = new GUIContent(summary, label.tooltip);
|
||||
|
||||
EditorGUI.PropertyField(position, property, label, includeChildren: true);
|
||||
}
|
||||
|
||||
private static string BuildSummary(SerializedProperty property)
|
||||
{
|
||||
string note = property.FindPropertyRelative("Note").stringValue;
|
||||
if (!string.IsNullOrWhiteSpace(note))
|
||||
return note;
|
||||
|
||||
string location = NameOf(property.FindPropertyRelative("Location").objectReferenceValue);
|
||||
string character = NameOf(property.FindPropertyRelative("Character").objectReferenceValue);
|
||||
string group = NameOf(property.FindPropertyRelative("Group").objectReferenceValue);
|
||||
|
||||
// 아무것도 안 채워진 새 항목은 기본 라벨(Element N) 유지
|
||||
if (location == null && character == null && group == null)
|
||||
return null;
|
||||
|
||||
var progress = property.FindPropertyRelative("Condition").FindPropertyRelative("MainProgress");
|
||||
int min = progress.FindPropertyRelative("Min").intValue;
|
||||
int max = progress.FindPropertyRelative("Max").intValue;
|
||||
string range = max >= 9999 ? $"[{min}~]" : $"[{min}~{max}]";
|
||||
|
||||
return $"{range} {location ?? "?"} · {character ?? "?"} · {group ?? "?"}";
|
||||
}
|
||||
|
||||
// 에셋별 표시 이름 (지정 안 됐으면 에셋 이름, 그마저 없으면 null)
|
||||
private static string NameOf(Object obj)
|
||||
{
|
||||
switch (obj)
|
||||
{
|
||||
case LocationData loc:
|
||||
return string.IsNullOrWhiteSpace(loc.DisplayName) ? loc.name : loc.DisplayName;
|
||||
case CharacterData ch:
|
||||
return string.IsNullOrWhiteSpace(ch.Name) ? ch.name : ch.Name;
|
||||
case DialogGroup grp:
|
||||
return string.IsNullOrWhiteSpace(grp.DialogGroupName) ? grp.name : grp.DialogGroupName;
|
||||
default:
|
||||
return obj != null ? obj.name : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/02_Scripts/Story/Editor/StoryBeatDrawer.cs.meta
Normal file
2
Assets/02_Scripts/Story/Editor/StoryBeatDrawer.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eade7ff33c9514b479d3f1e4ba2da912
|
||||
Reference in New Issue
Block a user