Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Canvas: How to scale the canvas to fill screen upon click

Discussion in '2D' started by hashmm2, Nov 1, 2019.

  1. hashmm2

    hashmm2

    Joined:
    Oct 21, 2019
    Posts:
    3
    My app recognizes an image target (Vuforia) and a info card pops up. Upon clicking that info card the card will center on screen and enlarge a bit. This is shown in the two pics below.

    How do I make it so that the canvas will scale to fit the screen completely?

    I do have the Canvas Scaler script but cannot use that for this purpose because the Canvas
    Render Mode is World Space. Changing the Render mode causes the issue of having the info cards completely fill up the screen upon recognizing the image, I don't want that happening. I want the user to select an info card from a variety of them.

    Any help would be appreciated
     

    Attached Files:

  2. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    635
    You could probably achieve the same effect by using a panel. You can then custom size your panel to appear like the box. Inside of the panel you can include toggle buttons to enlarge to full screen or minimize to a smaller size. Very simple to design and code.
     
    hashmm2 likes this.
  3. hashmm2

    hashmm2

    Joined:
    Oct 21, 2019
    Posts:
    3
    @MisterSkitz

    Hey, so I didn't quite understand what you mean so I used the following tutorial to guide me to Hide/Unhide the game object. The issue with this method is that it conflicts with the existing code since hiding the object prevents the code from being able to get certain pieces of information that it gets from those hidden objects.

    I also tried to change the screen render mode in code when the info card is clicked but that doesn't work either, not sure why, it just doesn't.

    Could you perhaps guide how to implement the toggle method u mentioned above.
     
    Last edited: Nov 14, 2019 at 4:04 PM