bugfixes
This commit is contained in:
@@ -17,15 +17,9 @@ namespace SplashEdit.EditorCode
|
||||
private SerializedProperty cutscenesProp;
|
||||
private SerializedProperty loadingScreenProp;
|
||||
private SerializedProperty previewBVHProp;
|
||||
private SerializedProperty previewRoomsPortalsProp;
|
||||
private SerializedProperty bvhDepthProp;
|
||||
|
||||
private bool _savedFog;
|
||||
private Color _savedFogColor;
|
||||
private FogMode _savedFogMode;
|
||||
private float _savedFogStart;
|
||||
private float _savedFogEnd;
|
||||
private bool _previewActive = false;
|
||||
|
||||
private bool showFog = true;
|
||||
private bool showCutscenes = true;
|
||||
private bool showDebug = false;
|
||||
@@ -41,22 +35,12 @@ namespace SplashEdit.EditorCode
|
||||
cutscenesProp = serializedObject.FindProperty("Cutscenes");
|
||||
loadingScreenProp = serializedObject.FindProperty("LoadingScreenPrefab");
|
||||
previewBVHProp = serializedObject.FindProperty("PreviewBVH");
|
||||
previewRoomsPortalsProp = serializedObject.FindProperty("PreviewRoomsPortals");
|
||||
bvhDepthProp = serializedObject.FindProperty("BVHPreviewDepth");
|
||||
|
||||
SaveAndApplyFogPreview();
|
||||
EditorApplication.update += OnEditorUpdate;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
EditorApplication.update -= OnEditorUpdate;
|
||||
RestoreFog();
|
||||
}
|
||||
|
||||
private void OnEditorUpdate()
|
||||
{
|
||||
if (_previewActive)
|
||||
ApplyFogPreview();
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
@@ -64,7 +48,7 @@ namespace SplashEdit.EditorCode
|
||||
serializedObject.Update();
|
||||
var exporter = (PSXSceneExporter)target;
|
||||
|
||||
DrawHeader();
|
||||
DrawExporterHeader();
|
||||
EditorGUILayout.Space(4);
|
||||
|
||||
DrawSceneSettings();
|
||||
@@ -82,7 +66,7 @@ namespace SplashEdit.EditorCode
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void DrawHeader()
|
||||
private void DrawExporterHeader()
|
||||
{
|
||||
EditorGUILayout.BeginVertical(PSXEditorStyles.CardStyle);
|
||||
EditorGUILayout.LabelField("Scene Exporter", PSXEditorStyles.CardHeaderStyle);
|
||||
@@ -138,15 +122,9 @@ namespace SplashEdit.EditorCode
|
||||
|
||||
EditorGUILayout.Space(2);
|
||||
EditorGUILayout.LabelField(
|
||||
$"<color=#aaaaaa>Preview: {fogNearUnity:F1} – {fogFarUnity:F1} units | " +
|
||||
$"GTE: {8000f / (density * 3f):F0} – {8000f / density:F0} SZ</color>",
|
||||
$"<color=#aaaaaa>GTE range: {fogNearUnity:F1} - {fogFarUnity:F1} units | " +
|
||||
$"{8000f / (density * 3f):F0} - {8000f / density:F0} SZ</color>",
|
||||
PSXEditorStyles.RichLabel);
|
||||
|
||||
ApplyFogPreview();
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderSettings.fog = false;
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
@@ -186,17 +164,18 @@ namespace SplashEdit.EditorCode
|
||||
EditorGUILayout.PropertyField(previewBVHProp, new GUIContent("Preview BVH"));
|
||||
if (previewBVHProp.boolValue)
|
||||
EditorGUILayout.PropertyField(bvhDepthProp, new GUIContent("BVH Depth"));
|
||||
EditorGUILayout.PropertyField(previewRoomsPortalsProp, new GUIContent("Preview Rooms/Portals"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
private void DrawSceneStats()
|
||||
{
|
||||
var exporters = FindObjectsOfType<PSXObjectExporter>();
|
||||
var exporters = FindObjectsByType<PSXObjectExporter>(FindObjectsSortMode.None);
|
||||
int total = exporters.Length;
|
||||
int active = exporters.Count(e => e.IsActive);
|
||||
int staticCol = exporters.Count(e => e.CollisionType == PSXCollisionType.Static);
|
||||
int dynamicCol = exporters.Count(e => e.CollisionType == PSXCollisionType.Dynamic);
|
||||
int triggerBoxes = FindObjectsOfType<PSXTriggerBox>().Length;
|
||||
int triggerBoxes = FindObjectsByType<PSXTriggerBox>(FindObjectsSortMode.None).Length;
|
||||
|
||||
EditorGUILayout.BeginVertical(PSXEditorStyles.CardStyle);
|
||||
EditorGUILayout.LabelField(
|
||||
@@ -205,49 +184,5 @@ namespace SplashEdit.EditorCode
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void SaveAndApplyFogPreview()
|
||||
{
|
||||
_savedFog = RenderSettings.fog;
|
||||
_savedFogColor = RenderSettings.fogColor;
|
||||
_savedFogMode = RenderSettings.fogMode;
|
||||
_savedFogStart = RenderSettings.fogStartDistance;
|
||||
_savedFogEnd = RenderSettings.fogEndDistance;
|
||||
_previewActive = true;
|
||||
ApplyFogPreview();
|
||||
}
|
||||
|
||||
private void ApplyFogPreview()
|
||||
{
|
||||
var exporter = (PSXSceneExporter)target;
|
||||
if (exporter == null) return;
|
||||
|
||||
if (!exporter.FogEnabled)
|
||||
{
|
||||
RenderSettings.fog = false;
|
||||
return;
|
||||
}
|
||||
|
||||
float gteScale = exporter.GTEScaling;
|
||||
int density = Mathf.Clamp(exporter.FogDensity, 1, 10);
|
||||
float fogFarSZ = 8000f / density;
|
||||
float fogNearSZ = fogFarSZ / 3f;
|
||||
|
||||
RenderSettings.fog = true;
|
||||
RenderSettings.fogColor = exporter.FogColor;
|
||||
RenderSettings.fogMode = FogMode.Linear;
|
||||
RenderSettings.fogStartDistance = fogNearSZ * gteScale / 4096f;
|
||||
RenderSettings.fogEndDistance = fogFarSZ * gteScale / 4096f;
|
||||
}
|
||||
|
||||
private void RestoreFog()
|
||||
{
|
||||
if (!_previewActive) return;
|
||||
_previewActive = false;
|
||||
RenderSettings.fog = _savedFog;
|
||||
RenderSettings.fogColor = _savedFogColor;
|
||||
RenderSettings.fogMode = _savedFogMode;
|
||||
RenderSettings.fogStartDistance = _savedFogStart;
|
||||
RenderSettings.fogEndDistance = _savedFogEnd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user