Getting data from a 2d array in Inspector


I have a matrix in my GameObject Inspector and I need to access it from another script.

Script to build the Inspector

ManholHealth : MonoBehaviour

public Image healthBar;
public Text probabPerc;
public AgingObjects[] colors ;...

public class AgingObjects
    public Color healtColor = new Color();
    public float[] Prob ;



What I need is to get the values in the elements of “prob”.

Sorry, this is maybe a newbie question, but I am one.

float value = manHolHealthInstance.colors[0].prob[indexOfTheElement];//just change 0 and indexofelement for the index of the objects you want to access

Thank you, but now the next problem, I’m trying to build a matrix like the one below, and I think I managed somehow, but if I try to print it to the console to check it, it doesn’t work. Whatever combination I try it comes with the same error. Is there another way to print 2d lists?

//transition matrix

// P[1]= {0.998,0.001,0.0005,0.0005,0.00};

// P[2]= {0.00,0.995,0.003,0.001,0.001};

// P[3]= {0.00,0.00,0.995,0.0025,0.0025};

// P[4]= {0.00,0.00,0.00,0.99,0.01};

// P[5]= {0.00,0.00,0.00,0.00,1.00};

 for(int j = 0; j<= manholeScript.colors.Length-1; j++)
            for (int i = 0; i <= manholeScript.colors[j].Prob.Length - 1; i++)
                float value = manholeScript.colors[j].Prob*;*

//foreach (float data in p)
// Debug.Log(data);


foreach (float[,] data in P) Error: Cannot convert type ‘System.Collections.Generic.List’ to ‘float[,]’