I am trying to create a function that dumps every Resources data in a Unity game to a file and was able to dump the video, audio, script names and the image on the screen from the current loaded scene.
I am stuck when trying to do the-same thing for the shader data such as Textures and Matrix, Vectors and int values and floats. I know I can obtain these formation with the Material.GetXXX
functions.
For example, I can currently obtain the main Texture
from the standard shader which has a Texture type property named _MainTex
with:
Material mat = gameObject.GetComponent<MeshRenderer>().material;
Texture mat1Tex = mat.GetTexture("_MainTex");
SaveTex(mat1Tex);
The problem is that I need to know the names of properties and which type it is such as Texture, Matrix, Float, Color and so on before I can obtain their values during run-time
I expect many shaders from third party sources to be in the project and it would be complicated to manually go over each shader, copy their property names and the type so that I can obtain the data.
Is there a way to get the shader property and the type required to retrieve their values with the Material.GetXXX
functions? If this is not possible, is there any way to dump the shader data individually?
Note:
This is not a save feature and I'm not looking for way to save and load game state. It's a plugin used to analyze and troubleshoot Unity games.