I am writing a blueprint “game” that allows the user to play with scalar parameters of a material instance via a umg ui. I can modify a material instance at runtime… I would like to save those new scalar values and apply them to the material instance once the game is exited. I don’t want that info to only live with a saved game but rather I want it to actually propagate to the material instance itself. Is this possible via blueprint alone?
Use case: Right now I am using set scalar parameter (target is mesh component) and retrieving the slider value from the umg ui I created. If I change the roughness of a material all the way to zero… and close the game… I want the edited material instance to retain that new roughness value of zero.
Also (side note) I have read the ue4 documentation about creating a dynamic material instance in order to modify at run-time. While this does work…I have found that I do not need to do so. I can simply set scalar parameter on the material of a mesh component without actually creating a dynamic material instance. Is this process happening automatically? Or do both methods yield the same result?
Is it possible to save modified parameters from a dynamic material instance and then apply them to the original material instance via blueprint after the game is exited?
I would save the parameters out to a file in some arbitrary format, then have a function that loads the parameters from said format into a dynamic material instance.
Sure, this works for saving and loading dynamic materials. But i want to pass those stored parameters from a saved game object to a material instance constant that already exists in the project. Basically pull info from the game and actually apply it to a uasset after game exit.
I want to launch a game that allows the player to customize a dynamic material instance. Then upon save I want to store those parameters in a save game object. But… this doesn’t change the material instance itself… so if I wanted to use this as a previs tool… all modifications would live with the game but I need them to propagate to the material that the dynamic material instance was created from. Is there a way to take the save game object data and pass it to a material .uasset?
well you can do it fine with BP, you just need to make the BP logic to save and read from files. it will read whatevers in the file when the game starts up
I think I am not articulating my problem well enough. I know how to save and load these parameters… which means in game persistence. However, I want the actual material source to be modified after run-time.Let me explain.
I run the game…
The bp creates a dynamic material instance of " M_Material_001"
Player modifies the parameters.
Player closes game
M_Material_001 somehow inherits the modified parameters from the dynamic material instance.
This is not a problem related to game persistence. It is a basically trying to recreate the functionality of the material instance editor inside a game.
Essentially I am trying to propagate modified material parameters from the dynamic material instance (created at runtime) back to the original material instance from which the dynamic one was created.
Posting this here for posterity. The comments were correct in handling it.
Sequence is as follows.
Load settings from file, applied to base material.
Adjust settings from material instance
Save settings from material instance into file.
You’re saving the settings that you make in the runtime, but in order for those settings to propagate they need to be set as the new defaults to the material that the instance stems from. If you’re concerned about needing like a Reset or something, you can always have a base settings file that can be loaded at any time.