gpt-4o-mini-2024-07-18· OpenAI
WildChat-4.8M (AI2)
I made a mesh inspector script for unity and a selection system too that has all…
- User
I made a mesh inspector script for unity and a selection system too that has all currently selected objects in a list, I want you to revamp my mesh inspector script to support multiples.
using NUnit.Framework; using Unity.Mathematics; using UnityEngine;
public class MeshInspector : MonoBehaviour { public GameObject Mesh;
codepublic Transform RezSpot; public Camera MainCam; public Camera ViewCam; public Transform PreservedParent; public Vector3 PreservedLocation; public Quaternion PreservedRotation; public CamOrbital CamOrbitScript; public void MeshViewerON() { // Disable the MainCam. MainCam.gameObject.SetActive(false); // Set the CameraOrbitScript's target to the mesh. CamOrbitScript.target = Mesh; // Enable the ViewCam. ViewCam.gameObject.SetActive(true); } public void MeshViewerOFF() { // Disable the ViewCam. ViewCam.gameObject.SetActive(false); // Set the CameraOrbitScript's target to null. CamOrbitScript.target = null; // Enable the MainCam. MainCam.gameObject.SetActive(true); } public void PreserveOriginals(Transform Mesh) { // Preserve Mesh's Parent, Local Position, Local Rotation. PreservedParent = Mesh.transform.parent; PreservedLocation = Mesh.transform.localPosition; PreservedRotation = Mesh.transform.localRotation; } public void RestoreOriginals() { // Remove Mesh from it's new parent. Mesh.transform.parent = null; // Restore Mesh's original parent. Mesh.transform.parent = PreservedParent; // Restore Mesh's original Local Pos, Local Rot. Mesh.transform.localPosition = PreservedLocation; Mesh.transform.localRotation = PreservedRotation; } public void InspectMesh() { // Enable the ViewCam & Disable the Maincam. MeshViewerON(); // Preserve Mesh's original parent, local pos, local rot. PreserveOriginals(Mesh.transform); // Unparent Mesh from it's parent. Mesh.transform.parent = null; // Assign RezSpot as Mesh's parent & reset it's local pos, local rot. Mesh.transform.parent = RezSpot; Mesh.transform.localPosition = Vector3.zero; Mesh.transform.localRotation = Quaternion.identity; } public void ExitInspector() { MeshViewerOFF(); RestoreOriginals(); } - Assistant