using UnityEngine; namespace SplashEdit.RuntimeCode { public class PSXObjectExporter : MonoBehaviour { public PSXBPP BitDepth = PSXBPP.TEX_8BIT; // Defines the bit depth of the texture (e.g., 4BPP, 8BPP) public bool MeshIsStatic = true; // Determines if the mesh is static, affecting how it's processed. Non-static meshes don't export correctly as of now. [HideInInspector] public PSXTexture2D Texture; // Stores the converted PlayStation-style texture [HideInInspector] public PSXMesh Mesh; // Stores the converted PlayStation-style mesh /// /// Converts the object's material texture into a PlayStation-compatible texture. /// public void CreatePSXTexture2D() { Renderer renderer = GetComponent(); if (renderer != null && renderer.sharedMaterial != null && renderer.sharedMaterial.mainTexture is Texture2D texture) { Texture = PSXTexture2D.CreateFromTexture2D(texture, BitDepth); Texture.OriginalTexture = texture; // Stores reference to the original texture } } /// /// Converts the object's mesh into a PlayStation-compatible mesh. /// public void CreatePSXMesh(float GTEScaling) { MeshFilter meshFilter = gameObject.GetComponent(); if (meshFilter != null) { Mesh = PSXMesh.CreateFromUnityMesh(meshFilter.sharedMesh, GTEScaling, transform, MeshIsStatic, Texture.Width, Texture.Height); } } } }