Question by
OfficialDeVel · Dec 16, 2020 at 12:19 PM ·
stringtable
Hide current object and show the one in string
Hello. I pretty new to this and I want to create script where I hide current gameobject and show the one which name I write in string. Using OnMouseDown on game object, it's much easier to do with new scene :/
Comment
Best Answer
Answer by xxmariofer · Dec 16, 2020 at 12:30 PM
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class ExampleClass : MonoBehaviour
{
public GameObject objectToHide;
public string gameObjectName;
void OnMouseDown()
{
objectToHide.SetActive(false);
GameObject.Find(gameObjectName).SetActive(true);
}
}