Split Editor and Runtime into separate namespaces, Created Texture and Mesh classes

This commit is contained in:
2025-01-13 20:28:06 +01:00
parent d1c734f078
commit 4c108f2ad6
8 changed files with 77 additions and 18 deletions

View File

@@ -1,19 +1,37 @@
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
using PSXSplash.Runtime; using PSXSplash.RuntimeCode;
[CustomEditor(typeof(PSXObjectExporter))] namespace PSXSplash.EditorCode
public class PSXObjectExporterEditor : Editor
{ {
[CustomEditor(typeof(PSXObjectExporter))]
public class PSXObjectExporterEditor : Editor
{
public override void OnInspectorGUI() public override void OnInspectorGUI()
{ {
base.OnInspectorGUI();
DrawDefaultInspector();
PSXObjectExporter comp = (PSXObjectExporter)target; PSXObjectExporter comp = (PSXObjectExporter)target;
if (GUILayout.Button("Export")) serializedObject.Update();
EditorGUILayout.BeginVertical("box");
EditorGUILayout.PropertyField(serializedObject.FindProperty("Mesh"));
if (GUILayout.Button("Export mesh"))
{ {
comp.Export(); comp.Mesh.Export();
}
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical("box");
EditorGUILayout.PropertyField(serializedObject.FindProperty("Texture"));
if (GUILayout.Button("Export texture"))
{
comp.Texture.Export();
}
EditorGUILayout.EndVertical();
serializedObject.ApplyModifiedProperties();
} }
} }
} }

View File

@@ -1,11 +1,10 @@
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
using PSXSplash.Runtime; using PSXSplash.RuntimeCode;
[CustomEditor(typeof(PSXSceneExporter))] [CustomEditor(typeof(PSXSceneExporter))]
public class PSXSceneExporterEditor : Editor { public class PSXSceneExporterEditor : Editor {
public override void OnInspectorGUI() { public override void OnInspectorGUI() {
base.OnInspectorGUI();
DrawDefaultInspector(); DrawDefaultInspector();
PSXSceneExporter comp = (PSXSceneExporter)target; PSXSceneExporter comp = (PSXSceneExporter)target;

13
Runtime/PSXMesh.cs Normal file
View File

@@ -0,0 +1,13 @@
using UnityEngine;
namespace PSXSplash.RuntimeCode {
[System.Serializable]
public class PSXMesh {
public bool TriangulateMesh = true;
public void Export() {
Debug.Log($"Export: {this}");
}
}
}

2
Runtime/PSXMesh.cs.meta Normal file
View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9025daa0c62549ee29d968f86c69eec9

View File

@@ -1,12 +1,16 @@
using UnityEngine; using UnityEngine;
namespace PSXSplash.Runtime namespace PSXSplash.RuntimeCode
{ {
public class PSXObjectExporter : MonoBehaviour public class PSXObjectExporter : MonoBehaviour
{ {
public PSXMesh Mesh;
public PSXTexture Texture;
public void Export() public void Export()
{ {
Debug.Log($"Export: {this.name}"); Debug.Log($"Export: {name}");
} }
} }
} }

View File

@@ -1,8 +1,7 @@
using UnityEditor;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
namespace PSXSplash.Runtime namespace PSXSplash.RuntimeCode
{ {
public class PSXSceneExporter : MonoBehaviour public class PSXSceneExporter : MonoBehaviour
{ {

22
Runtime/PSXTexture.cs Normal file
View File

@@ -0,0 +1,22 @@
using UnityEngine;
namespace PSXSplash.RuntimeCode {
public enum PSXTextureType {
TEX_4BPP,
TEX_8BPP,
TEX16_BPP
}
[System.Serializable]
public class PSXTexture
{
public PSXTextureType TextureType;
public bool Dithering = true;
public void Export() {
Debug.Log($"Export: {this}");
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6d64b6bb75da33720b928203b2780952