- Home /
GUI button disappears
If you press either the keyboard or the GUi Button, an object should be created. It is different in the way that it is created, but it creates the same object.
The problem is that when I press a key on the keyboard, the object is instantiate well. Button disappears altogether
So, I tried to create a new Button, but the normal cube works well The same thing happens with the new Button.
If you press another object, the Button becomes visible.
I want to know how to make the object disappear without pressing the Button. Note that Button's OnClick gets the CreateObj of this script
public static GameObject SelectedCom;
private GameObject _object;
public GameObject _GameObj;
public Transform UnitZenCom;
public GameObject ButtonOnOff;
void Start()
{
SelectedCom = transform.Find("Selected").gameObject;
}
void Update()
{
//syncopation(mouse button down (0) by Raycast
//and SelectedCom.SetActive(true); <<- state)
if (SelectedCom.activeSelf == true)
{
ButtonOnOff.SetActive(true);
if (Input.GetKeyDown(KeyCode.Q))
{
CreateObj();
}
}
}
public void CreateObj()
{
_object = Instantiate(_GameObj, Vector3.zero, Quaternion.identity) as GameObject;
_object.transform.localPosition = UnitZenCom.position;
}
Your answer
Follow this Question
Related Questions
GUI elements vanish when publishing 1 Answer
My GUI rockets(Texture) doesn't disappear when I fire the Rockets? 0 Answers
How to display a GUI label for a certain amount of time 2 Answers
Joysticks disappears Android 1 Answer
Hide/show GUI Buion 1 Answer