reference property of an object

Hello,

This is my first post here so hope to be in the right forum section. My question is the following:

i have a script, call it A, with:

public List<My_Object> myObjects = null;

this allow me to select from the inspector the size of the list. Let’s suppose that i select size = 1. Then i can drag and drop a game object of type My_Object inside the inspector in Element0 position. Let’s call this object TestObject. TestObject has a public variable

public int test = 3;

What i want to do is to create (in script A) a public list (let’s call it testList) by reading what is inside “Element0” of the list myObjects (in our case, there is TestObject there) and extract from there the value of the variable test and show it as Element0 of the list testList in the inspector.

This should happen befor entering in play mode.

Is it possible?if yes, how to do this?

Thanks

Create another public list, this time of integers:

public List<int> extractedValues = new List<int>();

Then, in Awake():

void Awake() {
  extractedValues.Clear();
  foreach (var element in myObjects) {
    int extracted = element.test;
    extractedValues.Add(extracted);
  }
}