I guys I have a problem: I want that when I click a UI button, my slider increase value but don’t work….why (I attach script)? In the same slider, I have another script that decrease slider on time (attach to the slider and this works). Do you think the two scripts conflict? Thank a lot.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class increaseslider : MonoBehaviour
{
public Slider healthbar;
public GameObject button;
public void OnClick()
{
healthbar.value += 20;
Destroy(button);
}
}
SECOND SCRIPT(SLIDER)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class stamina : MonoBehaviour
{
public Slider slider;
public float time = 3000f;
public AudioSource scream;
void Start()
{
slider.maxValue = 3000f;
slider.minValue = 0f;
}
void Update()
{
time -= Time.deltaTime;
slider.value = time;
if (slider.value <= 0)
{
scream.Play();
StartCoroutine(LateCall());
}
IEnumerator LateCall()
{
yield return new WaitForSeconds(2);
SceneManager.LoadScene("menu");
}
}
}