hi,
i want to compare the name of a prefab that gets instantiated and print a something, but the condition doesn’t seem to work.need help in this.
using UnityEngine;
using System.Collections;
public class prefabCreation_1 : MonoBehaviour {
//public GameObject startbutton;
public GameObject button;
bool onGameMode = true;
void Update()
{
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit hit;
if(onGameMode == true)
{
Instantiate(button, transform.position,transform.rotation);
//prefabCreation();
}
if (Physics.Raycast (ray, out hit, 100))
{
if(Input.GetMouseButtonUp(0))
{
if(hit.collider.gameObject.name == "startButton")
{
print ("working");
}
}
}
onGameMode = false;
}