I have a system in unity where theres a data class (called melt data) which is a scriptable object. The scriptable object will save and load data from a different class (called melt save) for each scriptable object. My scriptable object will be placed in a list and for each item in the list, it is to spawn a game object (called a meowmelt) which stores the scriptable object (melt data). Upon the meowmelt storing the melt data, the scriptable object is to load the save data and store that so that the meowmelt class can read from the scriptableobject data and the save data.
I have an issue where each meowmelt’s colour is to be loaded from the melt save data. Upon the data being loaded, it SHOULD set the renderer component to this colour, however this is not the case. I store the R, G, B and A values rather than an instance of colour as it doesn’t seem to be serializable, so a new instance of colour is made upon loading the data.
To make a meowmelt, I have a template melt that is set to inactive, as I said, for each melt data, this template is instantiated and set active, the data it reads from is set and then the script is started. After the data is loaded correctly, the melt colour should be set. I am aware that the line of code should set the colour correctly in theory, but what happens is they retain their default colour. I am also aware that the data loads correctly and before the colour is set as I can see a variable that shows the intended colour in the inspector
Stranger still, if I was to run the script with the template meowmelt set to active and with data, it will set all the other melts’ colours to that which is saved by the melt data of the template melt, but the template melt would remain white.
I think that there may be something fishy going on with the instances of the material, but I don’t fully understand it. Please could anyone help and provide any suggestions as to why this doesn’t seem to work?
Thank you
(this is where I set the colour, you can see that it stores the intended colour so that it can be seen in the inspector for debugging purposes.)
(With no template melt active, the colours are all default, they aren’t just white)

(With the template melt active, they all read from this melt’s intended colour. It is set before the other melts are active. Note how it is not shown on the template melt itsself.)
This shows that the intended colour is correct, however the actual colour is not correct.
This is my code for spawning a melt.
Thank you, any help is much appreciated. I am relatively new to unity, I do not fully understand the intricacies of how it works yet.



