Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Help! Need to Extract Material File during RUNTIME.

Discussion in 'General Graphics' started by demitrisabian, Mar 13, 2018.

?

Did you have understand my question?

  1. Hell ya

    0 vote(s)
    0.0%
  2. No Idea

    100.0%
  1. demitrisabian

    demitrisabian

    Joined:
    Feb 22, 2018
    Posts:
    1
    I have a strange goal I must accomplish and I'm pulling my hair out.

    I have some scripts running that are generating maps in Unity. These maps and certain materials in them only exist after pressing PLAY. If I PAUSE I can access scene hierarchy and do some edits.

    My problem is some of the Material Texture files are only generated during RUNTIME (PLAY). I see the file under material and Albedo.

    Is there anyway I can get this material that is being processed at RUNTIME to an image file??
     
  2. malak

    malak

    Joined:
    Jan 23, 2014
    Posts:
    65
    i'm looking for the same , did you find a solution ?
     
  3. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    576
    You have to understand the difference between material and texture. You cant "get this material to an image file" (you can bake it but its probably not what you mean). You can save your texture by writing an editor tool for it, that would get the texture from material, create new asset for it and save it in the asset database.

    Alternatively you can output your texture into a png https://docs.unity3d.com/ScriptReference/ImageConversion.EncodeToPNG.html

    Second case can be built into the game itself, and does not require editor scripting.