i need the variables from my components in the scene and put them in a list so i can use them later but fieldinfo is not working is there anther way for me to do this
using System.Reflection;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class AllObjs
{
public string ObjectName;
public Component[] ObjComponents;
public FieldInfo[] ComponentsValues;
}
public List<GameObject> InGameObjs;
public List<AllObjs> MyHierarchy;
void Start {
GameObject[] SceneHierarchy = GameObject.FindObjectsOfType<GameObject>();
foreach (GameObject GO in SceneHierarchy)
{
InGameObjs.Add(GO);
MyHierarchy.Add(new AllObjs());
MyHierarchy[MyHierarchy.Count - 1].ObjectName = GO.name;
MyHierarchy[MyHierarchy.Count - 1].ObjComponents = GO.GetComponents<Component>();
MyHierarchy[MyHierarchy.Count - 1].ComponentsValues = GO.GetComponents<Component>().GetType().GetFields();
}
}