Search Unity

Resolved Saving Material/Shader State

Discussion in 'Editor & General Support' started by lukamoon, Sep 14, 2021.

  1. lukamoon

    lukamoon

    Joined:
    Nov 15, 2018
    Posts:
    15
    Hi all,

    I've been trying to kind of come up with a "preset" system for materials/shader settings that can be accessed via scripts. I wanted it to be a bit more dynamic than just manually setting every value line by line in a script, and I know that Unity does have a preset system in 2018+ but I've not seen any scripting documentation for it and it seems like a glorified material clone. I was wondering what the best way to go about this was?

    I thought originally to just overwrite the properties in the .mat, but it seems like what is actually in the .mat file and what is configured in the shader are not always 1:1 (and, on top of that, i have keywords to take into account). Any thoughts would be appreciated! Much thanks.
     
  2. lukamoon

    lukamoon

    Joined:
    Nov 15, 2018
    Posts:
    15
    A quick update for anybody that finds this via Google/searching forums: I managed to fix the issue I described of "what is actually in the .mat file and what is configured in the shader are not always 1:1" by forcing assets to save, and then reading it, making it perfect for use in a scripted preset system!