Unity Community

Results 1 to 3 of 3

  1. Location
    Paris, France

    From a button to hide/unhide a mesh

    I have asked some times ago about that question but did not resolve it yet
    it maybe too easy to most of the members but simply I don't get the api to get that working
    so if someboy had an anwser thanks in advance
    here is the code
    The menus before are working fine
    private void ButtonDiamondW_OnClick(object source, ClickEventArgs e)

    component = GameObject.FindGameObjectsWithTag("perle_bagu");

    //print("This is component component[2]" ); // does not work too much red in the debugger

    //for(var j=0 ; j<component .length ; j++) {
    component [2].active = false;
    // does not work either so many entries in the debugger

    I am a programmer
    I program civilizations
    All of them

  2. Location
    Austin, TX
    You are not getting an answer because your question is vague. I see a few things going wrong here.

    1) using EventArgs did not work for me. For a messenger script I used the one at this link:


    2) to make a button you want to use Unity's GUI features which you can look for here:


    3) To search through the objects in your scene by name, use something like this:
    1.     Transform SearchInScene(string myType)
    2.     {
    3.             // Go through all Objects in scene to find the ones of that name
    4.         GameObject[] GOs =  GameObject.FindObjectsOfType( typeof( GameObject ) ) as GameObject[];
    5.         Transform theOneFound = null;
    6.         foreach ( GameObject GO in GOs )
    7.         {
    8.                 if( GO.name == myType)
    9.                 {
    10.                 theOneFound = GO.transform;
    11.                 // Find mesh here and do what you want...
    12.                 }
    13.         }
    14.         if(theOneFound) return theOneFound;
    15.         else return null;
    16.     }
    if (Unity) happiness++;

  3. Posts
    too much red in the debugger
    Lol :)

    Can you post the declaration for 'component'? Also, are you sure the 'component' array has at least 3 elements?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts