Search Unity

Resolved I don't know how to search to solve it

Discussion in 'Scripting' started by oaredkbnsitakey, Jan 16, 2021.

  1. oaredkbnsitakey

    oaredkbnsitakey

    Joined:
    Jan 16, 2021
    Posts:
    5
    This is a beginner's question.
    I want to press a button in the game and replace the cube with a sphere.
    I want to load the sphere when I press the button.
    I searched because it was a basic question.
    But I don't know how to find it in the official references.
    https://docs.unity3d.com/ja/2019.4/ScriptReference/index.html
    Please tell me the search method from the information on the left.
     
  2. Syco753

    Syco753

    Joined:
    Feb 11, 2013
    Posts:
    42
    Do you already have as script?

    You could attach your GameObjects (Cube and Sphere) to the Script:

    Code (CSharp):
    1. public GameObject myCube;
    2. public GameObject mySphere;
    3.  
    4. void Start()
    5. {
    6. myCube.SetActive(true);
    7. mySphere.SetActive(false);
    8. }
    9.  
    10. void PressMyButton()
    11. {
    12. myCube.SetActive(false);
    13. mySphere.SetActive(true);
    14. }
    Now you attach that Script to the button. How you can do that, you will se in that video:
     
  3. oaredkbnsitakey

    oaredkbnsitakey

    Joined:
    Jan 16, 2021
    Posts:
    5
    "SetActive"! Thank you very much. It was very helpful.
     
    Syco753 likes this.