Quantcast
Channel: Questions in topic: "obj"
Viewing all articles
Browse latest Browse all 167

Why does my Unity application can't find the Specular shader after build at runtime?

$
0
0
****Solved this by my own in the meanhile (see Update 3 at the bottom). But maybe it's helpful for any Googling Googler, so I'm not going to delete.**** (though this post is not even released by moderation right now lol) **System-informtions:** HP ProBook 450 G0 (Intel Core i5) Windows 8.1 64 bit Unity 4.6.1f1 (free version) Application built as standalone Windows player *Hint:* (For some reasons, like integrated Occulus SDK, I didn't use my original project for debugging and those screenshots, but the example scene from the author of that obj-loader mentioned later) **Description of my problem:** My purpose was to make Unity to load a .obj 3D model at runtime into my world. For this I used a parser I found at [everyday3d.com][1]. So ... everything seemed to work fine, I put that scripts into my project and was able to load obj files from my webspace, I even managed to add dynamicaly loaded behaviour from outside. Well so the model gets visible within the test environment of the Unity Editor: But when I build it and start the application, the model doesn't appear at runtime. What I get during debugging the development build is the exception visible in the screenshot: As far as I can reproduce, the problems begin with m = new Material(Shader.Find("Specular")); And yeah well ... I have no clue what happens afterwards. The "Build Agent" directory doesn't exist, when I try to inspect the further "path" of the given exception. I guess that's just some temporary help-code for the Unity interpreter? Anyway my applications seem to not find the Specular shader. I hope someone can help me :/ Update: Hm found something in the output_log.txt of my project (data folder). Can't get something new out of it but maybe you can: NullReferenceException at (wrapper managed-to-native) UnityEngine.Material:Internal_CreateWithShader (UnityEngine.Material,UnityEngine.Shader) at UnityEngine.Material..ctor (UnityEngine.Shader shader) [0x00006] in C:\BuildAgent\work\d63dfc6385190b60\artifacts\StandalonePlayerGenerated\ShaderBindings.cs:149 at OBJ.GetMaterial (.MaterialData md) [0x0000c] in D:\Source\Unity_test4_whereIsMyMonkey\Assets\OBJ\src\OBJ.cs:209 at OBJ.Build () [0x0002a] in D:\Source\Unity_test4_whereIsMyMonkey\Assets\OBJ\src\OBJ.cs:236 at OBJ+c__Iterator0.MoveNext () [0x001e2] in D:\Source\Unity_test4_whereIsMyMonkey\Assets\OBJ\src\OBJ.cs:73 Update 2: According to information inside the Unity Scripting [Documentation][2], Shaders will only be included into the build, if they were used otherwise in any scene or are stored in the Resources directory. So the next question: where are the standard shaders of unity located? Seems like I have to push them into the Resources folder. Update 3: Ok, this has been the right clue. Quick workaround: added a new material using the Specular shader into a folder named Resources. Thanks for your attention, anyway! [1]: http://www.everyday3d.com/blog/index.php/2010/05/24/loading-3d-models-runtime-unity3d/ [2]: http://docs.unity3d.com/ScriptReference/Shader.Find.html

Viewing all articles
Browse latest Browse all 167

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>