i’m trying to build a custom inspector to make life easier for customizing weapon stats in different behaviour states.
and everything’s pretty much working except a few things, i wanted to copy values of an array element to the other array elements.
when i press the “copy values to other state” button in the [BEGINNING] tab, it should replace the all the values of [HURT] with the ones from [BEGINNING], but i couldn’t wrap my head around replacing values of serialized properties.
i’ve got two for loops, am trying to replace values in “j” with values in “i”, something like this
for(int i = 0; i < statsArray.arraySize; i++)
{
// a bunch of codes to display other serialized properties in index "i", omitted for sanity's sake
if(GUILayout.Button("Copy Values To Other State",GUILayout.MaxWidth(250)))
{
SerializedProperty tempTemplate = statsArray.GetArrayElementAtIndex(i).Copy();
for(int j = 0; j < statsArray.arraySize; j++)
{
if(j != i)
{
statsArray.GetArrayElementAtIndex(j).objectReferenceValue = tempTemplate.objectReferenceValue; // doesn't work
statsArray.GetArrayElementAtIndex(j) = tempTemplate; // doesn't work too
}
}
}
}
i thought about using InsertArrayElementAtIndex() but afaik all this one does is just add an empty array element at the designated index.
i’m stumped now, any ideas?
