Search Unity

Eine Scene, 3 Canavas, die per Buttondruck gewechselt werden.

Discussion in 'Scripting' started by Deleted User, Jul 26, 2016.

  1. Deleted User

    Deleted User

    Guest

    Hello guys,
    I have make a menu for my iOS application. In this scene i have 3 canvases. There are not so different but at the bottom corner is a text with different informations.

    So, I need your help.

    In the menu are 2 buttons. The buttons change the text (the canvases).
    How can I do this? How can the buttons change the canvas?

    More informations:
    - Canavas 1 "startmenu_normal"
    - Canavas 2 "startmenu_appinformations"
    - Canavas 3 "startmenu_howtoplay"

    Thank you for your help :)
    (My english is not the best. Sorry for this)
     
    Last edited by a moderator: Jul 26, 2016
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,332
    These forums are English forums, so you should ask questions in that - you'll be much more likely to get answers.

    That being said, why do you have three different canvases?
     
  3. Deleted User

    Deleted User

    Guest

    Ok, I have change the language. I don't now that this forum is only in english. Thank you for your information.
     
  4. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,332
    Are you familiar with the button's OnClick? You can set the Canvase's gameobjects to active/unactive through their SetActive method.
     
  5. Deleted User

    Deleted User

    Guest

    I am familiar with button´s OnClick, but I have no idea how I have to use the Canavase´s. Can you give me a example for a script please.

    Thank you :)
     
  6. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    Code (CSharp):
    1. public GameObject canvas;
    2. public GameObject otherCanvas;
    3.  
    4. public void ToggleCanvas()
    5. {
    6.     canvas.SetActive(false);
    7.     otherCanvas.SetActive(true);
    8. }
     
  7. Deleted User

    Deleted User

    Guest

    OMG, thank you :) Thank you very much. It is so easy.