As a premise, I'm thinking of making a one-on-one match-up game.
What I want to achieve is that when the conclusion is reached, the two split screens will gradually expand and only the winning screen will be the one. The ideal would be:
↓
I was able to press the button to switch to only one screen, but I don't know how to gradually expand it to one screen.
Corresponding source codeusing System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraController: MonoBehaviour
{
GameObject Cam2Obj;
private Camera Cam;
private Camera Cam2;
// Start is called before the first frame update
void Start ()
{
Cam = Camera.main;// 1P camera
Cam2Obj = GameObject.Find ("2PCamera");// 2P camera
Cam2 = Cam2Obj.GetComponent
}
// Update is called once per frame
void Update ()
{
// Become a 1P only camera
if (Input.GetKey (KeyCode.E))
{
Cam.rect = new Rect (0.0f, 0.0f, 1.0f, 1.0f);
Cam2.rect = new Rect (0.0f, 0.0f, 1.0f, 0.0f);
}
// Only 2P camera
if (Input.GetKey (KeyCode.R))
{
Cam2.rect = new Rect (0.0f, 0.0f, 1.0f, 1.0f);
}
// The screen is split into two
if (Input.GetKey (KeyCode.T))
{
Cam.rect = new Rect (0.0f, 0.0f, 0.5f, 1.0f);
Cam2.rect = new Rect (0.5f, 0.0f, 0.5f, 1.0f);
}
}
}
I thought I could do something like Cam.rect.width = + 0.1f, but I couldn't.
Supplementary information (FW/tool version, etc.)The version of Unity is 2019.4.14f1.
Please let me know if there is any missing information.
-
Answer # 1
-
Answer # 2
[Unity] Split screen and multi-display How about referring to this article?
I think that if you adjust the size of the camera after dividing it, you will get closer to what you want to do.
Related articles
- aspnet c # screen transition dialog
- c # - i want to lock the screen itself except displayalert with xamarin
- c # - reflect the contents of the screen to linq
- i would like to know how to change the lock screen image of windows 10 with c #
- c # - how to display a desktop screen image in a cell with excel vba
- c # - i want to display the result screen when the interstitial advertisement is closed
- c # - i want to create a xamarin login screen
- c # - i want to move an object to the center of the screen in unityvr vr space
- c # - [unity] on the game screen, right-click menu display when an object is selected and when it is not selected
- c # - to know if the screen is being pressed inside a xamarin ios loop
- c # - i want to display list > types on the screen in order in the form of a double for statement
- c # - screen transition by dynamically created button
- c # - the load gradually increases when instantiate loop processing is performed in ienumerator
- c # - toolbox is not displayed even on the screen of visual studio design
- c # - screen transition is not possible in firebase, unity: statechanged
- html - elements expand to fill the screen width even though width is not specified
- c # - i want to expand the effective range of judgment processing in music games
- c # - i would like to make a transition by tapping the screen
- c # - make the image gradually transparent with unity
- c # - in a script? error cs1056: unexpected character'?' is displayed even though there is no
- candidates are not displayed even if i hit a period in c # opened in unity
- c # - no value is assigned when using if statement
- c # - the player character of unity rotates
- c # - touch judgment of unity object
- c # - i don't understand the code below
- c # - i want to specify a different url from the script side for the video player component of unity
- c # - conversion from enum type to enum type
- c # - [unity] an unintended transition occurs in the state transition of animator controller
Why not try using Mathf.Lerp () as well?
As for how to use
If you turn it with Update () like this, the process that x gradually changes from 0 to 100 is completed.
After that, I wondered if I should add a process to stop the process when it reaches the target size.
Time.deltaTime * Number
You can also change the speed of change by writing.