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

HoloLens throwing Shader.Find exception

Discussion in 'Scripting' started by jc_crash, Nov 7, 2019.

  1. jc_crash

    jc_crash

    Joined:
    Jul 30, 2019
    Posts:
    21
    Hi all,

    I have built a simple application which uses an OBJ runtime loader from the asset store. It requires that the "Standard (Specular setup)" shader is added to 'Always included shaders'. This is the only 'off normal' thing I did in the project.

    The project is built for HoloLens (and therefore enables XR and WMR). The project built and deployed correctly, but when I try to load the model (which works in editor), an exception is thrown in the following IL2CPP function:

    Code (CSharp):
    1. // UnityEngine.Shader UnityEngine.Shader::Find(System.String)
    2. extern "C" IL2CPP_METHOD_ATTR Shader_tE2731FF351B74AB4186897484FB01E000C1160CA * Shader_Find_m755654AA68D1C663A3E20A10E00CDC10F96C962B (String_t* ___name0, const RuntimeMethod* method)
    3. {
    4.     typedef Shader_tE2731FF351B74AB4186897484FB01E000C1160CA * (*Shader_Find_m755654AA68D1C663A3E20A10E00CDC10F96C962B_ftn) (String_t*);
    5.     static Shader_Find_m755654AA68D1C663A3E20A10E00CDC10F96C962B_ftn _il2cpp_icall_func;
    6.     if (!_il2cpp_icall_func)
    7.     _il2cpp_icall_func = (Shader_Find_m755654AA68D1C663A3E20A10E00CDC10F96C962B_ftn)il2cpp_codegen_resolve_icall ("UnityEngine.Shader::Find(System.String)");
    8.     Shader_tE2731FF351B74AB4186897484FB01E000C1160CA * retVal = _il2cpp_icall_func(___name0);
    9.     return retVal;
    10. }
    Any ideas would be appreciated.

    Thanks!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,971
    Put an object in one of your scenes that actually references the missing shader, see if it suddenly works: just because you added it to "always included shaders" doesn't mean something else down the long build chain doesn't remove it.

    If it suddenly works, then yeah, despite you saying keep it, it was getting stripped. If it doesn't work, check spelling on the shader name.
     
  3. jc_crash

    jc_crash

    Joined:
    Jul 30, 2019
    Posts:
    21
    @Kurt-Dekker thanks for the tip! I did exactly that and the application crashes on startup!
     
  4. SpandanaMatapathi

    SpandanaMatapathi

    Joined:
    Aug 10, 2020
    Posts:
    3
    @jc_crash were you able to solve this ?I am stuck at the same line and I a also trying to use the same shader and importer!