I have three game objects (statusBar1, statusBar2, statusBar3) on a canvas, each using a certain image. I want to use a single script to adjust the fillAmount of the objects in different ways. How do I find the specific game objects instead of just the Image component?
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class StatusBar : MonoBehaviour
{
Image statusBar;
void Start ()
{
statusBar = GetComponent<Image>();
// find gameobject with name statusBar1
// find gameobject with name statusBar2
// find gameobject with name statusBar3
}
void Update ()
{
statusBar1.fillAmount = something
statusBar2.fillAmount = somethingElse
statusBar3.fillAmount = somethingElseAgain
}
}