- Home /
Question by
prajaprihana · Nov 05, 2015 at 01:09 PM ·
multiplesetactivemultiple objects
please help me with AR multiple object
please help me, i wish when button "home" pressed it will only show (game object "home") "lt1" pressed it will only show (game object "lt1") "lt2" pressed it will only show (game object "lt2") i'm using setactive but it's not happen anything, please help me
using UnityEngine;
using System.Collections;
public class Srisoeta : MonoBehaviour {
public GUISkin guiSkin;
public float guiRatio;
public float sWidth;
public Vector3 GUIsF;
public GameObject home;
public GameObject lt1;
public GameObject lt2;
void Awake(){
sWidth = Screen.width;
guiRatio = sWidth/1920;
GUIsF = new Vector3(guiRatio,guiRatio,1);
}
void OnGUI(){
GUI.skin = guiSkin;
MultiObject ();
}
void MultiObject(){
GUI.matrix = Matrix4x4.TRS (new Vector3 (GUIsF.x, GUIsF.y, 0), Quaternion.identity, GUIsF);
if (GUI.Button (new Rect (20, 20, 256, 100), "home")) {
home.SetActive (true);
lt1.SetActive (false);
lt2.SetActive (false);
}
if (GUI.Button (new Rect (20, 150, 256, 100), "lt1")) {
home.SetActive (false);
lt1.SetActive (true);
lt2.SetActive (false);
}
if (GUI.Button (new Rect (20, 280, 256, 100), "lt2")) {
home.SetActive (false);
lt1.SetActive (false);
lt2.SetActive (true);
}
if(GUI.Button(new Rect(20,540,256,100),"Exit")){
Application.LoadLevel(1);
}
}
}
Comment
I brought that code into Unity (5.1.3f1), and it seems like it works fine for me. Are you just trying to have each button enable it's corresponding GameObject and disable the others?
Your answer
![](https://koobas.hobune.stream/wayback/20220612044004im_/https://answers.unity.com/themes/thub/images/avi.jpg)