Answers for "hwo to make something appear and disappear in unity"

C#
1

unity how to make a ui disappear

using UnityEngine;
using UnityEngine.UI;

public class ScriptName : MonoBehaviour
{
    [SerializeField]
    private CanvasGroup Canvas;

	// makes canvas invisible
    void Awake()
    {
        Canvas.alpha = 0f;
        Canvas.interactable = false;
        Canvas.blocksRaycasts = false;
    }

	// when button is clicked canvas becomes visible
    public void Click()
    {
    	print("work");
        Canvas.alpha = 1f;
        Canvas.interactable = true;
        Canvas.blocksRaycasts = true;
    }
}
Posted by: Guest on February-09-2020
1

how to make an object appear and disappear in unity

void Update() {
   if (Input.GetMouseButtonDown(0)) {
     gameObject.active = true;
   }
   if (Input.GetMouseButtonDown(1)) {
     gameObject.active = false;
   }
 }
Posted by: Guest on July-10-2020

Code answers related to "hwo to make something appear and disappear in unity"

C# Answers by Framework

Browse Popular Code Answers by Language