0
\$\begingroup\$

Is it possible to load a material from a file path? Or, otherwise parse a .mat file saved on disk to a Material usable at runtime?

I had naively thought it would be possible to assign the bytes from a .mat file, as read by File.ReadAllBytes to a Material object, but that does not seem to work.

\$\endgroup\$
7
  • 1
    \$\begingroup\$ Loading assets from files at runtime is what asset bundles used to be for and which you should now do with addressables. Unfortunately asset bundles are deprecated and I don't have enough experience with addressables to feel confident to write a proper answer. \$\endgroup\$
    – Philipp
    Oct 30, 2020 at 8:50
  • 1
    \$\begingroup\$ However, this seems kind of like an XY problem to me. Can you tell us more about why you want to load a material at runtime from a path and not just import it into your project and assign it in the Unity editor? \$\endgroup\$
    – Philipp
    Oct 30, 2020 at 9:05
  • \$\begingroup\$ @Philipp think millions of materials already on a server etc \$\endgroup\$
    – ina
    Oct 30, 2020 at 17:32
  • \$\begingroup\$ can't get addressable to work with assets from an external project, for other projects to use, unfortunately gamedev.stackexchange.com/questions/186472/… \$\endgroup\$
    – ina
    Oct 30, 2020 at 17:33
  • \$\begingroup\$ Why would you load millions of materials from a server? Are you talking about user-generated content? How much do you really want the users to be able to customize? \$\endgroup\$
    – Philipp
    Oct 30, 2020 at 21:25

0

You must log in to answer this question.

Browse other questions tagged .