bugfixes
This commit is contained in:
@@ -41,96 +41,62 @@ namespace SplashEdit.EditorCode
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
DrawHeader();
|
||||
|
||||
EditorGUILayout.Space(5);
|
||||
|
||||
_interactionFoldout = DrawFoldoutSection("Interaction Settings", _interactionFoldout, () =>
|
||||
|
||||
// Header card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.Label(EditorGUIUtility.IconContent("d_Selectable Icon"), GUILayout.Width(30), GUILayout.Height(30));
|
||||
EditorGUILayout.BeginVertical();
|
||||
EditorGUILayout.LabelField("PSX Interactable", PSXEditorStyles.CardHeaderStyle);
|
||||
EditorGUILayout.LabelField("Player interaction trigger for PS1", PSXEditorStyles.RichLabel);
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.EndHorizontal();
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
_interactionFoldout = PSXEditorStyles.DrawFoldoutCard("Interaction Settings", _interactionFoldout, () =>
|
||||
{
|
||||
EditorGUILayout.PropertyField(_interactionRadius);
|
||||
|
||||
// Button selector with visual
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.PrefixLabel("Interact Button");
|
||||
_interactButton.intValue = EditorGUILayout.Popup(_interactButton.intValue, ButtonNames);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
|
||||
EditorGUILayout.PropertyField(_isRepeatable);
|
||||
|
||||
|
||||
if (_isRepeatable.boolValue)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_cooldownFrames, new GUIContent("Cooldown (frames)"));
|
||||
|
||||
// Show cooldown in seconds
|
||||
|
||||
float seconds = _cooldownFrames.intValue / 60f;
|
||||
EditorGUILayout.LabelField($"≈ {seconds:F2} seconds at 60fps", EditorStyles.miniLabel);
|
||||
EditorGUILayout.LabelField($"~ {seconds:F2} seconds at 60fps", EditorStyles.miniLabel);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
|
||||
EditorGUILayout.PropertyField(_showPrompt);
|
||||
});
|
||||
|
||||
_advancedFoldout = DrawFoldoutSection("Advanced", _advancedFoldout, () =>
|
||||
|
||||
EditorGUILayout.Space(2);
|
||||
|
||||
_advancedFoldout = PSXEditorStyles.DrawFoldoutCard("Advanced", _advancedFoldout, () =>
|
||||
{
|
||||
EditorGUILayout.PropertyField(_requireLineOfSight);
|
||||
EditorGUILayout.PropertyField(_interactionOffset);
|
||||
});
|
||||
|
||||
DrawLuaEventsInfo(new[] { "onInteract" });
|
||||
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Lua events card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("Lua Events", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.DrawSeparator(2, 4);
|
||||
EditorGUILayout.LabelField("onInteract", PSXEditorStyles.RichLabel);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void DrawHeader()
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
|
||||
|
||||
GUILayout.Label(EditorGUIUtility.IconContent("d_Selectable Icon"), GUILayout.Width(30), GUILayout.Height(30));
|
||||
|
||||
EditorGUILayout.BeginVertical();
|
||||
GUILayout.Label("PSX Interactable", EditorStyles.boldLabel);
|
||||
GUILayout.Label("Player interaction trigger for PS1", EditorStyles.miniLabel);
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private bool DrawFoldoutSection(string title, bool isExpanded, System.Action drawContent)
|
||||
{
|
||||
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
|
||||
isExpanded = EditorGUILayout.Foldout(isExpanded, title, true, EditorStyles.foldoutHeader);
|
||||
|
||||
if (isExpanded)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
drawContent?.Invoke();
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.Space(3);
|
||||
|
||||
return isExpanded;
|
||||
}
|
||||
|
||||
private void DrawLuaEventsInfo(string[] events)
|
||||
{
|
||||
EditorGUILayout.Space(5);
|
||||
|
||||
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
GUILayout.Label("Lua Events", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
foreach (var evt in events)
|
||||
{
|
||||
GUILayout.Label($"• {evt}", EditorStyles.miniLabel);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
268
Editor/Inspectors/PSXComponentEditors2.cs
Normal file
268
Editor/Inspectors/PSXComponentEditors2.cs
Normal file
@@ -0,0 +1,268 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using SplashEdit.RuntimeCode;
|
||||
|
||||
namespace SplashEdit.EditorCode
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom inspector for PSXAudioClip component.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(PSXAudioClip))]
|
||||
public class PSXAudioClipEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
// Header card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("PSX Audio Clip", PSXEditorStyles.CardHeaderStyle);
|
||||
|
||||
PSXAudioClip audioClip = (PSXAudioClip)target;
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (audioClip.Clip != null)
|
||||
PSXEditorStyles.DrawStatusBadge("Clip Set", PSXEditorStyles.Success, 70);
|
||||
else
|
||||
PSXEditorStyles.DrawStatusBadge("No Clip", PSXEditorStyles.Warning, 70);
|
||||
|
||||
if (audioClip.Loop)
|
||||
PSXEditorStyles.DrawStatusBadge("Loop", PSXEditorStyles.AccentCyan, 50);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Properties card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("Clip Settings", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.DrawSeparator(2, 4);
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("ClipName"), new GUIContent("Clip Name",
|
||||
"Name used to identify this clip in Lua (Audio.Play(\"name\"))."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("Clip"), new GUIContent("Audio Clip",
|
||||
"Unity AudioClip to convert to PS1 SPU ADPCM format."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("SampleRate"), new GUIContent("Sample Rate",
|
||||
"Target sample rate for the PS1 (lower = smaller, max 44100)."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("Loop"), new GUIContent("Loop",
|
||||
"Whether this clip should loop when played."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("DefaultVolume"), new GUIContent("Volume",
|
||||
"Default playback volume (0-127)."));
|
||||
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Info card
|
||||
if (audioClip.Clip != null)
|
||||
{
|
||||
PSXEditorStyles.BeginCard();
|
||||
float duration = audioClip.Clip.length;
|
||||
int srcRate = audioClip.Clip.frequency;
|
||||
EditorGUILayout.LabelField(
|
||||
$"Source: {srcRate} Hz, {duration:F2}s, {audioClip.Clip.channels}ch\n" +
|
||||
$"Target: {audioClip.SampleRate} Hz SPU ADPCM",
|
||||
PSXEditorStyles.InfoBox);
|
||||
PSXEditorStyles.EndCard();
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom inspector for PSXPlayer component.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(PSXPlayer))]
|
||||
public class PSXPlayerEditor : Editor
|
||||
{
|
||||
private bool _dimensionsFoldout = true;
|
||||
private bool _movementFoldout = true;
|
||||
private bool _navigationFoldout = true;
|
||||
private bool _physicsFoldout = true;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
// Header card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("PSX Player", PSXEditorStyles.CardHeaderStyle);
|
||||
EditorGUILayout.LabelField("First-person player controller for PS1", PSXEditorStyles.RichLabel);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Dimensions
|
||||
_dimensionsFoldout = PSXEditorStyles.DrawFoldoutCard("Player Dimensions", _dimensionsFoldout, () =>
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("playerHeight"), new GUIContent("Height",
|
||||
"Camera eye height above the player's feet."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("playerRadius"), new GUIContent("Radius",
|
||||
"Collision radius for wall sliding."));
|
||||
});
|
||||
|
||||
EditorGUILayout.Space(2);
|
||||
|
||||
// Movement
|
||||
_movementFoldout = PSXEditorStyles.DrawFoldoutCard("Movement", _movementFoldout, () =>
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("moveSpeed"), new GUIContent("Walk Speed",
|
||||
"Walk speed in world units per second."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("sprintSpeed"), new GUIContent("Sprint Speed",
|
||||
"Sprint speed in world units per second."));
|
||||
});
|
||||
|
||||
EditorGUILayout.Space(2);
|
||||
|
||||
// Navigation
|
||||
_navigationFoldout = PSXEditorStyles.DrawFoldoutCard("Navigation", _navigationFoldout, () =>
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("maxStepHeight"), new GUIContent("Max Step Height",
|
||||
"Maximum height the agent can step up."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("walkableSlopeAngle"), new GUIContent("Walkable Slope",
|
||||
"Maximum walkable slope angle in degrees."));
|
||||
PSXEditorStyles.DrawSeparator(4, 4);
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("navCellSize"), new GUIContent("Cell Size (XZ)",
|
||||
"Voxel size in XZ plane (smaller = more accurate but slower)."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("navCellHeight"), new GUIContent("Cell Height",
|
||||
"Voxel height (smaller = more accurate vertical resolution)."));
|
||||
});
|
||||
|
||||
EditorGUILayout.Space(2);
|
||||
|
||||
// Jump & Gravity
|
||||
_physicsFoldout = PSXEditorStyles.DrawFoldoutCard("Jump & Gravity", _physicsFoldout, () =>
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("jumpHeight"), new GUIContent("Jump Height",
|
||||
"Peak jump height in world units."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("gravity"), new GUIContent("Gravity",
|
||||
"Downward acceleration in world units per second squared."));
|
||||
});
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom inspector for PSXPortalLink component.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(PSXPortalLink))]
|
||||
public class PSXPortalLinkEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
PSXPortalLink portal = (PSXPortalLink)target;
|
||||
|
||||
// Header card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("PSX Portal Link", PSXEditorStyles.CardHeaderStyle);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
bool valid = portal.RoomA != null && portal.RoomB != null && portal.RoomA != portal.RoomB;
|
||||
if (valid)
|
||||
PSXEditorStyles.DrawStatusBadge("Valid", PSXEditorStyles.Success, 55);
|
||||
else
|
||||
PSXEditorStyles.DrawStatusBadge("Invalid", PSXEditorStyles.Error, 60);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Room references card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("Connected Rooms", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.DrawSeparator(2, 4);
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("RoomA"), new GUIContent("Room A",
|
||||
"First room connected by this portal."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("RoomB"), new GUIContent("Room B",
|
||||
"Second room connected by this portal."));
|
||||
|
||||
// Validation warnings
|
||||
if (portal.RoomA == null || portal.RoomB == null)
|
||||
{
|
||||
EditorGUILayout.Space(4);
|
||||
EditorGUILayout.LabelField("Both Room A and Room B must be assigned for export.", PSXEditorStyles.InfoBox);
|
||||
}
|
||||
else if (portal.RoomA == portal.RoomB)
|
||||
{
|
||||
EditorGUILayout.Space(4);
|
||||
EditorGUILayout.LabelField("Room A and Room B must be different rooms.", PSXEditorStyles.InfoBox);
|
||||
}
|
||||
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Portal size card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("Portal Dimensions", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.DrawSeparator(2, 4);
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("PortalSize"), new GUIContent("Size (W, H)",
|
||||
"Size of the portal opening (width, height) in world units."));
|
||||
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom inspector for PSXRoom component.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(PSXRoom))]
|
||||
public class PSXRoomEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
PSXRoom room = (PSXRoom)target;
|
||||
|
||||
// Header card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("PSX Room", PSXEditorStyles.CardHeaderStyle);
|
||||
if (!string.IsNullOrEmpty(room.RoomName))
|
||||
EditorGUILayout.LabelField(room.RoomName, PSXEditorStyles.RichLabel);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Properties card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("Room Settings", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.DrawSeparator(2, 4);
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("RoomName"), new GUIContent("Room Name",
|
||||
"Optional display name for this room (used in editor gizmos)."));
|
||||
|
||||
PSXEditorStyles.DrawSeparator(4, 4);
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("VolumeSize"), new GUIContent("Volume Size",
|
||||
"Size of the room volume in local space."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("VolumeOffset"), new GUIContent("Volume Offset",
|
||||
"Offset of the volume center relative to the transform position."));
|
||||
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Info card
|
||||
PSXEditorStyles.BeginCard();
|
||||
Bounds wb = room.GetWorldBounds();
|
||||
Vector3 size = wb.size;
|
||||
EditorGUILayout.LabelField(
|
||||
$"World bounds: {size.x:F1} x {size.y:F1} x {size.z:F1}",
|
||||
PSXEditorStyles.InfoBox);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Editor/Inspectors/PSXComponentEditors2.cs.meta
Normal file
2
Editor/Inspectors/PSXComponentEditors2.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3fd7a7bcc7d0ff841b158f2744d48010
|
||||
@@ -232,9 +232,16 @@ namespace SplashEdit.EditorCode
|
||||
serializedObject.Update();
|
||||
|
||||
Vector2 res = PSXCanvas.PSXResolution;
|
||||
EditorGUILayout.LabelField($"PSX Canvas ({res.x}x{res.y})", EditorStyles.boldLabel);
|
||||
|
||||
// Header card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField($"PSX Canvas ({res.x}x{res.y})", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Properties card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("canvasName"), new GUIContent("Canvas Name",
|
||||
"Name used from Lua: UI.FindCanvas(\"name\"). Max 24 chars."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("startVisible"), new GUIContent("Start Visible",
|
||||
@@ -244,18 +251,18 @@ namespace SplashEdit.EditorCode
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("defaultFont"), new GUIContent("Default Font",
|
||||
"Default custom font for text elements. If empty, uses built-in system font (8x16)."));
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
PSXEditorStyles.DrawSeparator(6, 6);
|
||||
|
||||
// Force Canvas configuration button
|
||||
if (GUILayout.Button($"Reset Canvas to {res.x}x{res.y}"))
|
||||
if (GUILayout.Button($"Reset Canvas to {res.x}x{res.y}", PSXEditorStyles.SecondaryButton))
|
||||
{
|
||||
PSXCanvas.InvalidateResolutionCache();
|
||||
((PSXCanvas)target).ConfigureCanvas();
|
||||
}
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Element summary
|
||||
// Element summary card
|
||||
PSXCanvas canvas = (PSXCanvas)target;
|
||||
int imageCount = canvas.GetComponentsInChildren<PSXUIImage>(true).Length;
|
||||
int boxCount = canvas.GetComponentsInChildren<PSXUIBox>(true).Length;
|
||||
@@ -263,14 +270,16 @@ namespace SplashEdit.EditorCode
|
||||
int progressCount = canvas.GetComponentsInChildren<PSXUIProgressBar>(true).Length;
|
||||
int total = imageCount + boxCount + textCount + progressCount;
|
||||
|
||||
EditorGUILayout.HelpBox(
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField(
|
||||
$"Elements: {total} total\n" +
|
||||
$" Images: {imageCount} | Boxes: {boxCount}\n" +
|
||||
$" Texts: {textCount} | Progress Bars: {progressCount}",
|
||||
total > 128 ? MessageType.Warning : MessageType.Info);
|
||||
PSXEditorStyles.InfoBox);
|
||||
|
||||
if (total > 128)
|
||||
EditorGUILayout.HelpBox("PS1 UI system supports max 128 elements total across all canvases.", MessageType.Error);
|
||||
EditorGUILayout.LabelField("PS1 UI system supports max 128 elements total across all canvases.", PSXEditorStyles.InfoBox);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
@@ -286,9 +295,15 @@ namespace SplashEdit.EditorCode
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.LabelField("PSX UI Image", EditorStyles.boldLabel);
|
||||
// Header card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("PSX UI Image", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Properties card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("elementName"), new GUIContent("Element Name",
|
||||
"Name used from Lua: UI.FindElement(canvas, \"name\"). Max 24 chars."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("sourceTexture"), new GUIContent("Source Texture",
|
||||
@@ -298,13 +313,19 @@ namespace SplashEdit.EditorCode
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("tintColor"), new GUIContent("Tint Color",
|
||||
"Color multiply applied to the image (white = no tint)."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("startVisible"));
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
// Texture size warning
|
||||
PSXUIImage img = (PSXUIImage)target;
|
||||
if (img.SourceTexture != null)
|
||||
{
|
||||
if (img.SourceTexture.width > 256 || img.SourceTexture.height > 256)
|
||||
EditorGUILayout.HelpBox("Texture exceeds 256x256. It will be resized during export.", MessageType.Warning);
|
||||
{
|
||||
EditorGUILayout.Space(4);
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("Texture exceeds 256x256. It will be resized during export.", PSXEditorStyles.InfoBox);
|
||||
PSXEditorStyles.EndCard();
|
||||
}
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
@@ -321,13 +342,20 @@ namespace SplashEdit.EditorCode
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.LabelField("PSX UI Box", EditorStyles.boldLabel);
|
||||
// Header card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("PSX UI Box", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Properties card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("elementName"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("boxColor"), new GUIContent("Box Color",
|
||||
"Solid fill color rendered as a FastFill primitive."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("startVisible"));
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
@@ -343,9 +371,15 @@ namespace SplashEdit.EditorCode
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.LabelField("PSX UI Text", EditorStyles.boldLabel);
|
||||
// Header card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("PSX UI Text", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Properties card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("elementName"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("defaultText"), new GUIContent("Default Text",
|
||||
"Initial text content. Max 63 chars. Change at runtime via UI.SetText()."));
|
||||
@@ -354,24 +388,33 @@ namespace SplashEdit.EditorCode
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("fontOverride"), new GUIContent("Font Override",
|
||||
"Custom font for this text element. If empty, uses the canvas default font or built-in system font (8x16)."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("startVisible"));
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
// Character count
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Warnings and info
|
||||
PSXUIText txt = (PSXUIText)target;
|
||||
if (!string.IsNullOrEmpty(txt.DefaultText) && txt.DefaultText.Length > 63)
|
||||
EditorGUILayout.HelpBox("Text exceeds 63 characters and will be truncated.", MessageType.Warning);
|
||||
{
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("Text exceeds 63 characters and will be truncated.", PSXEditorStyles.InfoBox);
|
||||
PSXEditorStyles.EndCard();
|
||||
EditorGUILayout.Space(4);
|
||||
}
|
||||
|
||||
// Font info
|
||||
PSXEditorStyles.BeginCard();
|
||||
PSXFontAsset font = txt.GetEffectiveFont();
|
||||
if (font != null)
|
||||
{
|
||||
EditorGUILayout.HelpBox(
|
||||
EditorGUILayout.LabelField(
|
||||
$"Font: {font.name} ({font.GlyphWidth}x{font.GlyphHeight} glyphs)",
|
||||
MessageType.Info);
|
||||
PSXEditorStyles.InfoBox);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("Using built-in system font (8x16 glyphs).", MessageType.Info);
|
||||
EditorGUILayout.LabelField("Using built-in system font (8x16 glyphs).", PSXEditorStyles.InfoBox);
|
||||
}
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
@@ -387,9 +430,15 @@ namespace SplashEdit.EditorCode
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.LabelField("PSX UI Progress Bar", EditorStyles.boldLabel);
|
||||
// Header card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("PSX UI Progress Bar", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Properties card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("elementName"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("backgroundColor"), new GUIContent("Background Color",
|
||||
"Color shown behind the fill bar."));
|
||||
@@ -399,13 +448,12 @@ namespace SplashEdit.EditorCode
|
||||
"Starting progress (0-100). Change via UI.SetProgress()."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("startVisible"));
|
||||
|
||||
PSXEditorStyles.DrawSeparator(6, 4);
|
||||
|
||||
// Preview bar
|
||||
Rect r = EditorGUILayout.GetControlRect(false, 16);
|
||||
PSXUIProgressBar bar = (PSXUIProgressBar)target;
|
||||
EditorGUI.DrawRect(r, bar.BackgroundColor);
|
||||
Rect fill = r;
|
||||
fill.width *= bar.InitialValue / 100f;
|
||||
EditorGUI.DrawRect(fill, bar.FillColor);
|
||||
PSXEditorStyles.DrawProgressBar(bar.InitialValue / 100f, "Preview", bar.FillColor, 16);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
@@ -424,11 +472,18 @@ namespace SplashEdit.EditorCode
|
||||
|
||||
PSXFontAsset font = (PSXFontAsset)target;
|
||||
|
||||
EditorGUILayout.LabelField("PSX Font Asset", EditorStyles.boldLabel);
|
||||
// Header card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("PSX Font Asset", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// ── Source font (TTF/OTF) ──
|
||||
EditorGUILayout.LabelField("Auto-Convert from Font", EditorStyles.miniBoldLabel);
|
||||
// Source font card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("Auto-Convert from Font", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.DrawSeparator(2, 4);
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("sourceFont"), new GUIContent("Source Font (TTF/OTF)",
|
||||
"Assign a Unity Font (TrueType/OpenType). Click 'Generate Bitmap' to rasterize it.\n" +
|
||||
"Glyph cell dimensions are auto-derived from the font metrics."));
|
||||
@@ -440,102 +495,121 @@ namespace SplashEdit.EditorCode
|
||||
if (font.SourceFont != null)
|
||||
{
|
||||
EditorGUILayout.Space(2);
|
||||
if (GUILayout.Button("Generate Bitmap from Font", GUILayout.Height(28)))
|
||||
if (GUILayout.Button("Generate Bitmap from Font", PSXEditorStyles.PrimaryButton, GUILayout.Height(28)))
|
||||
{
|
||||
Undo.RecordObject(font, "Generate PSX Font Bitmap");
|
||||
font.GenerateBitmapFromFont();
|
||||
}
|
||||
|
||||
if (font.FontTexture == null)
|
||||
EditorGUILayout.HelpBox(
|
||||
EditorGUILayout.LabelField(
|
||||
"Click 'Generate Bitmap' to create the font texture.\n" +
|
||||
"If generation fails, check that the font's import settings have " +
|
||||
"'Character' set to 'ASCII Default Set'.", MessageType.Info);
|
||||
"'Character' set to 'ASCII Default Set'.", PSXEditorStyles.InfoBox);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space(8);
|
||||
|
||||
// ── Manual bitmap ──
|
||||
EditorGUILayout.LabelField("Manual Bitmap Source", EditorStyles.miniBoldLabel);
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("fontTexture"), new GUIContent("Font Texture",
|
||||
"256px wide bitmap. Glyphs in ASCII order from 0x20 (space). " +
|
||||
"Transparent = background, opaque = foreground."));
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// ── Glyph metrics ──
|
||||
// If using auto-convert, these are set by GenerateBitmapFromFont.
|
||||
// For manual bitmaps, the user sets them directly.
|
||||
EditorGUILayout.LabelField("Glyph Metrics", EditorStyles.miniBoldLabel);
|
||||
// Manual bitmap card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("Manual Bitmap Source", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.DrawSeparator(2, 4);
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("fontTexture"), new GUIContent("Font Texture",
|
||||
"256px wide bitmap. Glyphs in ASCII order from 0x20 (space). " +
|
||||
"Transparent = background, opaque = foreground."));
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// Glyph metrics card
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("Glyph Metrics", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.DrawSeparator(2, 4);
|
||||
|
||||
if (font.SourceFont != null && font.FontTexture != null)
|
||||
{
|
||||
// Show as read-only when auto-generated
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.IntField(new GUIContent("Glyph Width", "Auto-derived from font. Re-generate to change."), font.GlyphWidth);
|
||||
EditorGUILayout.IntField(new GUIContent("Glyph Height", "Auto-derived from font. Re-generate to change."), font.GlyphHeight);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
EditorGUILayout.HelpBox("Glyph dimensions are auto-derived when generating from a font.\n" +
|
||||
"Change the Font Size slider and re-generate to adjust.", MessageType.Info);
|
||||
EditorGUILayout.LabelField("Glyph dimensions are auto-derived when generating from a font.\n" +
|
||||
"Change the Font Size slider and re-generate to adjust.", PSXEditorStyles.InfoBox);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Editable for manual bitmap workflow
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("glyphWidth"), new GUIContent("Glyph Width",
|
||||
"Width of each glyph cell in pixels. Must divide 256 evenly (4, 8, 16, or 32)."));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("glyphHeight"), new GUIContent("Glyph Height",
|
||||
"Height of each glyph cell in pixels."));
|
||||
}
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
// ── Layout info ──
|
||||
// Layout info card
|
||||
PSXEditorStyles.BeginCard();
|
||||
int glyphsPerRow = font.GlyphsPerRow;
|
||||
int rowCount = font.RowCount;
|
||||
int totalH = font.TextureHeight;
|
||||
int vramBytes = totalH * 128; // 128 bytes per row at 4bpp 256px
|
||||
int vramBytes = totalH * 128;
|
||||
|
||||
EditorGUILayout.HelpBox(
|
||||
EditorGUILayout.LabelField(
|
||||
$"Layout: {glyphsPerRow} glyphs/row, {rowCount} rows\n" +
|
||||
$"Texture: 256 x {totalH} pixels (4bpp)\n" +
|
||||
$"VRAM: {vramBytes} bytes ({vramBytes / 1024f:F1} KB)\n" +
|
||||
$"Glyph cell: {font.GlyphWidth} x {font.GlyphHeight}",
|
||||
MessageType.Info);
|
||||
PSXEditorStyles.InfoBox);
|
||||
|
||||
// Show advance width status
|
||||
if (font.AdvanceWidths != null && font.AdvanceWidths.Length >= 95)
|
||||
{
|
||||
int minAdv = 255, maxAdv = 0;
|
||||
for (int i = 1; i < 95; i++) // skip space
|
||||
for (int i = 1; i < 95; i++)
|
||||
{
|
||||
if (font.AdvanceWidths[i] < minAdv) minAdv = font.AdvanceWidths[i];
|
||||
if (font.AdvanceWidths[i] > maxAdv) maxAdv = font.AdvanceWidths[i];
|
||||
}
|
||||
EditorGUILayout.HelpBox(
|
||||
EditorGUILayout.LabelField(
|
||||
$"Advance widths: {minAdv}-{maxAdv}px (proportional spacing stored)",
|
||||
MessageType.Info);
|
||||
PSXEditorStyles.InfoBox);
|
||||
}
|
||||
else if (font.FontTexture != null)
|
||||
{
|
||||
EditorGUILayout.HelpBox(
|
||||
EditorGUILayout.LabelField(
|
||||
"No advance widths stored. Click 'Generate Bitmap' to compute them.",
|
||||
MessageType.Warning);
|
||||
PSXEditorStyles.InfoBox);
|
||||
}
|
||||
PSXEditorStyles.EndCard();
|
||||
|
||||
// ── Validation ──
|
||||
// Validation
|
||||
if (font.FontTexture != null)
|
||||
{
|
||||
if (font.FontTexture.width != 256)
|
||||
EditorGUILayout.HelpBox($"Font texture must be 256 pixels wide (currently {font.FontTexture.width}).", MessageType.Error);
|
||||
{
|
||||
EditorGUILayout.Space(4);
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField($"Font texture must be 256 pixels wide (currently {font.FontTexture.width}).", PSXEditorStyles.InfoBox);
|
||||
PSXEditorStyles.EndCard();
|
||||
}
|
||||
|
||||
if (256 % font.GlyphWidth != 0)
|
||||
EditorGUILayout.HelpBox($"Glyph width ({font.GlyphWidth}) must divide 256 evenly. " +
|
||||
"Valid values: 4, 8, 16, 32.", MessageType.Error);
|
||||
{
|
||||
EditorGUILayout.Space(4);
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField($"Glyph width ({font.GlyphWidth}) must divide 256 evenly. " +
|
||||
"Valid values: 4, 8, 16, 32.", PSXEditorStyles.InfoBox);
|
||||
PSXEditorStyles.EndCard();
|
||||
}
|
||||
|
||||
// Show preview
|
||||
// Preview
|
||||
EditorGUILayout.Space(4);
|
||||
EditorGUILayout.LabelField("Preview", EditorStyles.miniBoldLabel);
|
||||
PSXEditorStyles.BeginCard();
|
||||
EditorGUILayout.LabelField("Preview", PSXEditorStyles.CardHeaderStyle);
|
||||
PSXEditorStyles.DrawSeparator(2, 4);
|
||||
Rect previewRect = EditorGUILayout.GetControlRect(false, 64);
|
||||
GUI.DrawTexture(previewRect, font.FontTexture, ScaleMode.ScaleToFit);
|
||||
PSXEditorStyles.EndCard();
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
Reference in New Issue
Block a user