I can’t seem to figure out a way to sort the list of gameobjects that are collected by tag name, that have different scripts, with the same int name, but different values. I want to sort the collection once gathered and the arrange by “start channel” of each… ascending from 1.2.3.4… etc.
public class FXManager : MonoBehaviour
{
private List<GameObject> effects = new List<GameObject>();
public List<Effect> effect = new List<Effect>();
void Start()
{
foreach (GameObject item in GameObject.FindGameObjectsWithTag("Effect"))
{
effects.Add(item);
FXTrigger fXTrigger = item.GetComponent<FXTrigger>();
if (fXTrigger != null)
{
Effect fx = new Effect();
fx.FX_Type = fXTrigger.FX_Type;
fx.channelsUsed = fXTrigger.channelsUsed;
fx.startChannel = fXTrigger.startChannel;
effect.Add(fx);
}
FXLighting3ch fxLighting3Ch = item.GetComponent<FXLighting3ch>();
if (fxLighting3Ch != null)
{
Effect fx = new Effect();
fx.FX_Type = fxLighting3Ch.FX_Type;
fx.channelsUsed = fxLighting3Ch.channelsUsed;
fx.startChannel = fxLighting3Ch.startChannel;
effect.Add(fx);
}
FXRamp1ch fxRamp1Ch = item.GetComponent<FXRamp1ch>();
if (fxRamp1Ch != null)
{
Effect fx = new Effect();
fx.FX_Type = fxRamp1Ch.FX_Type;
fx.channelsUsed = fxRamp1Ch .channelsUsed;
fx.startChannel = fxRamp1Ch.startChannel;
effect.Add(fx);
}
}
}
}
[Serializable]
public class Effect
{
public string FX_Type;
public int channelsUsed;
public int startChannel;
}