I managed to get some sort of cover for the cameras that we want "locked", it's just a grey screen covering the camera with the timer and the camera number:
This is the script I used to "unlock" the cameras, it basically just deletes the grey cover on the canvas of the camera:
It can be reused on other objects by just dragging the script in the scripts folder onto that object and then dragging the cover to delete into the Gameobject field:
Next I'll cover the simpler update I made, which was the random patterns for the invisible floor.
It was as simple as I thought it would be, I just made three prefabs with different patterns of floors like this:
Then in the script, generated a random number, stored it and used a switch case to decide which pattern to set to active. All the patterns are set to inactive by default, then when the script is started (On spawn/respawn), it will generate a new number and set the pattern to active. As a note, it might be worth setting the prefabs to inactive in the start function just to be safe:
You would then pass in the objects through the inspector in the invis floor manager:
Now for the more confusing part, the dynamic resolution.
Just before our lecture today Dario informed me that the timer text was half way cut off when he tested the game. After looking into it today, I came to the horrible realisation that I forgot to make the camera canvases dynamic. This meant that I had to basically remake the canvases with the settings to change based on screen resolution. Luckily, Unity is a very useful engine, in the canvas settings there's an option to change the canvas to scale with the screen size:
Then change the reference resolution to 1920 x 1080 as that's the most common resolution.
I had to do this for all the canvases, then I had to change the position of the Timers and Camera counters again, then anchor the text to the sides of the screen. Anchoring the text keeps the text in the specified position no matter what size of the screen, although I have found that the text gets very small when playing on a large resolution. Also, the grey camera cover doesn't fully work when on 16:10 aspect ratio, but that's the only one is doesn't really work with other than Free Aspect:
A bit of a longer update.
I managed to get some sort of cover for the cameras that we want "locked", it's just a grey screen covering the camera with the timer and the camera number:
This is the script I used to "unlock" the cameras, it basically just deletes the grey cover on the canvas of the camera:
It can be reused on other objects by just dragging the script in the scripts folder onto that object and then dragging the cover to delete into the Gameobject field:
Next I'll cover the simpler update I made, which was the random patterns for the invisible floor.
It was as simple as I thought it would be, I just made three prefabs with different patterns of floors like this:
Then in the script, generated a random number, stored it and used a switch case to decide which pattern to set to active. All the patterns are set to inactive by default, then when the script is started (On spawn/respawn), it will generate a new number and set the pattern to active. As a note, it might be worth setting the prefabs to inactive in the start function just to be safe:
You would then pass in the objects through the inspector in the invis floor manager:
Now for the more confusing part, the dynamic resolution.
Just before our lecture today Dario informed me that the timer text was half way cut off when he tested the game. After looking into it today, I came to the horrible realisation that I forgot to make the camera canvases dynamic. This meant that I had to basically remake the canvases with the settings to change based on screen resolution. Luckily, Unity is a very useful engine, in the canvas settings there's an option to change the canvas to scale with the screen size:
Then change the reference resolution to 1920 x 1080 as that's the most common resolution.
I had to do this for all the canvases, then I had to change the position of the Timers and Camera counters again, then anchor the text to the sides of the screen. Anchoring the text keeps the text in the specified position no matter what size of the screen, although I have found that the text gets very small when playing on a large resolution. Also, the grey camera cover doesn't fully work when on 16:10 aspect ratio, but that's the only one is doesn't really work with other than Free Aspect:
Timer anchor:
Camera counter anchor: