Added 3d pseduo canvas

This commit is contained in:
Pasha Bibko
2026-01-20 13:59:02 +00:00
parent bc1c12d97b
commit fe2a5179ee
6 changed files with 411 additions and 9 deletions

View File

@@ -0,0 +1,19 @@
using System;
using UnityEngine;
namespace InterfaceOff.WorldScene
{
public class ExternalCamera : MonoBehaviour
{
[SerializeField] private Camera ExternalCam;
private RenderTexture RenderTexture;
private void Awake()
{
RenderTexture = new RenderTexture(width: 1920, height: 1080, depth: 16);
ExternalCam.targetTexture = RenderTexture;
}
public Texture GetTexture() => RenderTexture;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: cfd8d92b06194cf98ee7011df76811cc
timeCreated: 1768912839

View File

@@ -1,6 +1,8 @@
using System.IO;
using System;
using System.IO;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
namespace InterfaceOff.WorldScene
{
@@ -8,13 +10,15 @@ namespace InterfaceOff.WorldScene
{
private static PlayerController Instance;
private PlayerFrameInfo[] Frames;
[SerializeField] private WindowSpawner ActiveWindowSpawner;
[SerializeField] private LineRenderer BulletTracerRenderer;
[SerializeField] private Transform BulletTracerStart;
[SerializeField] private Transform BulletTracerEnd;
[field: SerializeField] public int FrameIndex { get; private set; }
[SerializeField] private int[] DeathIndices;
[SerializeField] private ExternalCamera ExternalCamera;
[SerializeField] private Image FrontLayerImage;
private const int MAX_WINDOWS = 20;
@@ -23,6 +27,8 @@ namespace InterfaceOff.WorldScene
private void Awake()
{
/* Hides the cursor as a custom one is used */
/* Loads the JSON, temporary. TODO: Insert the JSON into this .cs file */
string json = File.ReadAllText(Application.dataPath + "/Resources/playerframe.json");
Frames = JsonUtility.FromJson<PlayerFrameInfoArray>(json).FrameInfo;
@@ -66,5 +72,10 @@ namespace InterfaceOff.WorldScene
BulletTracerRenderer.enabled = Frames[FrameIndex].ShootGun;
}
}
private void LateUpdate()
{
FrontLayerImage.material.mainTexture = ExternalCamera.GetTexture();
}
}
}

View File

@@ -20,6 +20,7 @@ namespace InterfaceOff
[field: SerializeField] private Canvas GameCanvas { get; set; }
[field: SerializeField] private GameObject DeathInfo { get; set; }
[field: SerializeField] private SpawnableWindowType[] WindowTypes { get; set; }
[field: SerializeField] private GameObject Parent { get; set; }
private int TotalSpawnWeight { get; set; }
[field: SerializeField] public int SpawnedWindowCount { get; private set; }
@@ -63,7 +64,7 @@ namespace InterfaceOff
private void SpawnNewRandomWindow()
{
/* Creates the gameobject with a random class */
GameObject go = Instantiate(SampleChild, GameCanvas.transform);
GameObject go = Instantiate(SampleChild, Parent.transform);
go.SetActive(true);
Type type = GetRandomWindowType();
@@ -121,7 +122,7 @@ namespace InterfaceOff
{
/* Destroys all children and stops them from spawning */
AutoSpawn = false;
foreach (Transform child in GameCanvas.transform)
foreach (Transform child in Parent.transform)
{
WindowBase window = child.GetComponent<WindowBase>();
if (DebugUtils.IsNotNull(window))