Added a back renderer to the portal

This commit is contained in:
2025-04-30 09:41:19 +01:00
parent b86c9f7a14
commit e1be308f05
3 changed files with 99 additions and 9 deletions

View File

@@ -19,7 +19,7 @@ public class PortalCamera : MonoBehaviour
Vector3 m_Rot;
// Initialistion function for the camera
public void InitCamera(MeshRenderer renderer, PortalManager creator, Vector3 rot)
public void InitCamera(MeshRenderer[] renderers, PortalManager creator, Vector3 rot)
{
// Transfers the passed rotation to be stored within the class
m_Rot = rot;
@@ -42,7 +42,11 @@ public class PortalCamera : MonoBehaviour
// Links the camera to the mesh renderer
m_Camera.targetTexture = m_RenderTexture; // Sets it's camera to display to the render texture instead of the screen
m_RenderMaterial.mainTexture = m_RenderTexture; // Sets the material to use the render texture as it's texture
renderer.material = m_RenderMaterial; // Set's the renderer to use the material
foreach (Renderer renderer in renderers)
{
renderer.material = m_RenderMaterial;
}
}
// Update is called every frame

View File

@@ -9,7 +9,7 @@ public class PortalManager : MonoBehaviour
[Header("Set References")]
[SerializeField] GameObject m_CameraPrefab;
[SerializeField] MeshRenderer m_PortalRenderer;
[SerializeField] MeshRenderer[] m_Renderers;
[Header("Points")]
[SerializeField] Transform m_PlayerPoint;
@@ -45,7 +45,7 @@ public class PortalManager : MonoBehaviour
m_PortalCamera = cam.GetComponentInChildren<PortalCamera>();
// Initialises the camera so it renders to the portal and not the screen
m_PortalCamera.InitCamera(m_PortalRenderer, this, transform.parent.localEulerAngles * 2.0f);
m_PortalCamera.InitCamera(m_Renderers, this, transform.parent.localEulerAngles * 2.0f);
}
// Updates is called every frame