Search Unity

Swapping shaders in code

Discussion in 'Scripting' started by Lokken, Jul 15, 2009.

  1. Lokken

    Lokken

    Joined:
    Apr 23, 2009
    Posts:
    436
    Hello all

    I am running into an odd problem with shader changes in the editor and the results when i build the project (for web and standalone so far)

    I have the user double click on a material face and have the shader change for a short moment to indicate they clicked.

    This works fine in the editor. However both in the web player and in standalone builds it does not behave the same. Normally the effect is the face retains the same color, it just loses all shading so it looks like it lights up.

    The swap happens in web and exe form but it just shows grey, as if no color is being applied.

    I have ruled out the shader itself being the problem as i have actually set the shader to switch to to the faces default shader. So in the editor it looks like no change happens to the surface but in the web/exe versions it still switches to a grey color.

    So anyone have an idea why I may be having issues swapping shaders in a built game but not in the editor?

    Thanks!

    L
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,603
    ensure that the shader is used on some material on some prefab that is part of the build, otherwise the reason might be that it is just not compiled and present in the build.
     
  3. Lokken

    Lokken

    Joined:
    Apr 23, 2009
    Posts:
    436
    Just in case anyone searches and finds this thread dreamora has now answered my question twice :)

    The shader was not used initially and needed to go into a 'resources' folder.

    Thanks again!

    L