- Home /
Activate animation and Deactivate all unused animation
Hi, I will try to implement an interface on my canvas. I have 8 panels and own buttons. I want to manage animation of panels with 8 different buttons. But I could not make a script :( When I click the button related panel will appear than others will disappear. I can create an event on the each buttons for each panels but it is a long way according to my experience. If you any suggestion for a script coulg you please share me? thx
Answer by DASLAN · Apr 26, 2021 at 12:09 PM
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class AllObjectsHide : MonoBehaviour { public GameObject[] obje; public GameObject ShowObject;
public void Start()
{
obje = GameObject.FindGameObjectsWithTag("Pannels");
for (int i = 0; i < obje.Length; i++)
{
obje[i].SetActive(false);
}
}
public void ShowOne()
{
if (ShowObject == obje[0])
{
ShowObject.SetActive(false);
}
else
{
ShowObject.SetActive(true);
}
}
}
// Tag define for all objects which will hide after press the button. // "ShowObject" component defined for Showing object // This script is linked to Button On Click function. // 2 functions added under button component // 1- Start() function Added from script // 2- ShowOne() function added from script // This items should be repeat for all buttons