- Home /
Question by
NikolaNikolov96 · Dec 08, 2015 at 12:01 PM ·
inspectorslider
Script for multiple sliders
Hi, Guys
I'm making a script which gets all elements by tag name, and then you can manipulate their alpha channel.The problem is that for now it gives just one slider for all of the objects : sdsd.jpg but i want it to make a slider for each individual object : ![alt text][1] My code so far is :
using UnityEngine;
using System.Collections;
public class ChangingAlphaValues : MonoBehaviour {
public GameObject[] targets;
[Range(0, 1)]
public float opacity= 1;
void Update ()
{
ChangingAlphaValue();
}
public void ChangingAlphaValue()
{
targets = GameObject.FindGameObjectsWithTag("ChangingAlphaValues");
foreach (GameObject item in targets)
{
item.GetComponent<Renderer>().material.color = new Color(0, 0, 0, opacity);
SliderMaker();
};
}
public void SliderMaker()
{
}
}
I already asked in the forum and I was given this answer :
" You'll have to make a small class:
[System.Serializable]
public class AlphaTarget {
public GameObject target;
public float alpha = 1f;
}
Make an array of those "
But I couldn't implement it and fully understand it.Sorry if I'm too annoying but I'm new in Unity and in C# aswell [1]: /storage/temp/59481-sdsd-1.jpg
sdsd-1.jpg
(6.6 kB)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612051648im_/https://answers.unity.com/themes/thub/images/avi.jpg)