I have a strange issue for the past week or so. So I'm working on a 3D mobile application and I've been testing the app on and off on my android phone.
On scene 01, I have a slider for the color and it changes a certain material's color. After I'm happy with the color that I've chosen, I go then and hit the button which loads scene 02. On scene 02 the new color of the material is maintained. This happens on the Unity Editor on PC and it works great. This also used to happen when I tested the application on my phone (android) and everything worked fine.
Now to get to the issue, starting since last week, I started optimising the game for the mobile platform since it had like 20-30 fps or so and some spikes. Since then, if i am on the Editor on PC, when i change the material's color in scene 01 , it's also persisting in scene 02. BUT when I do the same on the mobile phone , for some reason when scene 02 is loaded, I still have the color of the material that the application was built with.
For example: I set the material's color to RED on Unity PC, then I build the application, and when I test the application on my phone, even if I change the color from RED to BLUE, on scene 02 it's still RED.
Now I don't know why this happens, I'm thinking maybe I've messed up some Player Settings ??? Or is there even a setting that has this kind of impact?
I started replacing the Shader (Lit) with Shader (Simple Lit) for most of the objects that are stationary, but I kept the Shader (Lit) on the object that I want to change the material's color. Maybe it has something to do with this?
Does it have anything to do with the Graphics API or something? Is there anything caches wrongfully that I have to manually clean? I still don't understand why on the PC Editor it works fine between the scenes, but on mobile it gets reset.
What resources do you need me to provide?
I have three sliders, for red, green and blue, and I'm assigning the values back to the color of the material.
Summary of the code:
public Material material;
public void MethodCalledInUI()
{
Color color = material.color;
color.r = redSlider.value;
color.g = greenSlider.value;
color.b = blueSlider.value;
material.color = color;
}
I also tried to use PlayerPrefs to set up the material and it still does not work. (before I didn't use any PlayerPrefs for the material and it worked just fine on both platforms).