Search Unity

Material Preview

Discussion in 'Scripting' started by DrDecipher, Aug 13, 2014.

  1. DrDecipher

    DrDecipher

    Joined:
    Dec 5, 2012
    Posts:
    54
    I'm working on a custom material editor window.

    The Inspector preview in the Unity interface is something I want to replicate.

    I do not know, but suspect that Unity has a scene, somewhere hidden, with a camera, lights and geometry that is rendered separately and then updates the window.

    Is is possible to trigger, or include a different scene during the GUI update?

    Thanks,
    Doc
     
  2. Fr33Ke

    Fr33Ke

    Joined:
    Aug 12, 2014
    Posts:
    11
  3. DrDecipher

    DrDecipher

    Joined:
    Dec 5, 2012
    Posts:
    54
    Thanks...clever:) but I'm looking to replicate the 'Material Preview' as it is in the Inspector.

    Any thoughts?

    Is it possible to render a scene from file?
     
    Last edited: Aug 13, 2014
  4. Fr33Ke

    Fr33Ke

    Joined:
    Aug 12, 2014
    Posts:
    11
    i think its not possible to render a scene from file.

    Ohhh Idea :D

    make sphere and add script to make it rotateble than do the materials with ocular cashs tool and you will get some kind of that thing what you want :) also use scripts from that tool, But do not start to sell it !
     
  5. DrDecipher

    DrDecipher

    Joined:
    Dec 5, 2012
    Posts:
    54
    I was trying to avoid having the sphere and camera in the scene, but that is possible to make a mini scene and hide it out of the way if I'm following what you mean.
     
  6. Fr33Ke

    Fr33Ke

    Joined:
    Aug 12, 2014
    Posts:
    11
    Yup make mini scene :) and cmera :p
     
  7. OcularCash

    OcularCash

    Joined:
    Sep 8, 2012
    Posts:
    4
    Thanks for the plug Fr33ke. But in this case, you would actually use Graphics.DrawMesh to draw a mesh in a given camera with a given material, then render the camera in the editor window. You can use RenderTexture if you have Unity Pro or you can place a script on a camera in the scene that creates an empty texture and gets the pixels from that camera in the OnPostRender function.
     
    Last edited: Sep 2, 2014