My "public Image" does not show on play once I drag the Image into the inspector in its slot. I am trying to make an ability hud with cooldown time that fills in a 360 like a clock showing the time til you can use again. Can anyone help me solve why it will not show. The script I have created makes no errors popup.
Heres the code Im using
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LightSlugAttack : MonoBehaviour
{
[Header("Ability 1")]
public Image lightabilityImage1;
public float cooldown1 = 5;
bool isCooldown = false;
public KeyCode ability1;
void Start()
{
lightabilityImage1.fillAmount = 0;
}
void Update()
{
Ability1();
}
void Ability1()
{
if (Input.GetKey(ability1) && isCooldown == false)
{
isCooldown = true;
lightabilityImage1.fillAmount = 1;
}
if (isCooldown)
{
lightabilityImage1.fillAmount -= 1 / cooldown1 * Time.deltaTime;
if (lightabilityImage1.fillAmount <= 0)
{
lightabilityImage1.fillAmount = 0;
isCooldown = false;
}
}
}
}
↧