Webgl build problems
Well, I've searched everywhere but I can't find any sort of answer so I'm hoping I can receive some help here. I'm experiencing three huge problems when I build my game using the webgl platform. The first is that all my shaders either have some weird new offset or the colors are slightly out of wack.The second problem is that only some of my reflection probes work while other's aren't doing anything, I also recieve this error upon loading up scenes where this is happening "PPtr cast failed when dereferencing! Casting from Shader to Texture! UnityEditor.DockArea:OnGUI()". the last problem that I'm having (although this may not be webgl build specific) is that my character's mesh is distorted. Any help is appreciated :)
Answer by Statement · Oct 22, 2015 at 07:30 PM
Sounds like you got a corrupt metafile for some shader.
If you got a more recent version than 4.2 try deleting your Library folder.
Note: Projects created in Unity 4.2 and earlier may not have .meta files if not explicitly enabled. Deleting the Library folder in these projects will lead to data loss and permanent project corruption because both the generated internal formats of your assets and the meta data were stored in the Library folder.
However, it is always safe to delete the Library folder (while the project is not open in Unity) as all its data is generated from what is stored in the Assets and ProjectSettings folders. This also means that the Library folder should not be included in version control.
Do you have a longer callstack? Also try to break up your questions so there's a post each. For example right now I am providing an answer to one of three topics. Not everyone can answer all questions.
I tried this but still didn't work. Also, in response to your suggestion, I posted all three here in case the problems we're directly related to each other or that it may help diagnose my problem. I have no idea what a callstack is so sorry I can't really answer that question. Thanks for trying to help :).
You can view the entire log or upload it to some paste site like pastebin and give me the link.
http://docs.unity3d.com/$$anonymous$$anual/LogFiles.html
A call stack is the chain of functions called that generated the log. You have the top part of the call stack already in there (UnityEditor.DockArea:OnGUI()). It could be interesting to see what the call stack looks like to figure out which system throws the error. It could also be that there is no visible call stack because it was called from native code. In that case you only see that one frame.
The best clue I got so far is that some editor window expects a texture but for some reason it got a shader. Perhaps you have been toying with editor extensions? I don't know why that error happens but PPtrs are persistent pointers. Each object that you or Unity creates is assigned a PPtr. I believe the PPtrs are stored in scene files and any resource bundles that Unity manages. If you open up a scene file with a text editor, you can spot them in the yaml. Let's look at a snip from one of my files.
--- !u!124 &503149942
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 503149940}
m_Enabled: 1
--- !u!92 &503149943
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 503149940}
m_Enabled: 1
Here, 503149942, 503149940 and 503149943 would be examples of these PPtrs (if I remember it right). What I guess is that somewhere there is a variable that happens to point to a shader ins$$anonymous$$d of a texture. One far fetch/a hunch is that perhaps you had a variable called foo that used to be of type Shader, but then you changed the type of foo to Texture. I don't know if Unity would correct that by setting it to 0 or if it would have a reference to that shader that used to sit there.
Ok so I got curious. I added a component to a scene that has a public Shader foo;
without setting it to anything. This is what Unity saves:
--- !u!114 &788221524
$$anonymous$$onoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 788221522}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b4a5c37aba2283546b84dd0eaaf88e45, type: 3}
m_Name:
m_EditorClassIdentifier:
foo: {fileID: 0}
Here, we can see foo: {fileID: 0}
- it's not set to anything. Ok, let's give foo a shader reference:
--- !u!114 &788221524
$$anonymous$$onoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 788221522}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b4a5c37aba2283546b84dd0eaaf88e45, type: 3}
m_Name:
m_EditorClassIdentifier:
foo: {fileID: 4800000, guid: f294816f329f42d4295989333f95f30a, type: 3}
It says foo: {fileID: 4800000, guid: f294816f329f42d4295989333f95f30a, type: 3}
I don't know what fileID means in this context though. Looking in the shaders metafile we see that the guid matches.
fileFormatVersion: 2
guid: f294816f329f42d4295989333f95f30a
timeCreated: 1445552297
licenseType: Free
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
Ok, so then I changed the type of foo to Texture ins$$anonymous$$d of Shader and saved the scene (without touching the field in the inspector)
--- !u!114 &788221524
$$anonymous$$onoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 788221522}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b4a5c37aba2283546b84dd0eaaf88e45, type: 3}
m_Name:
m_EditorClassIdentifier:
foo: {fileID: 4800000, guid: f294816f329f42d4295989333f95f30a, type: 3}
We can see that fileID, guid and type are unchanged. I guess this means that if something tried to access foo and expect it was a Texture, Unity would get angry because f294816f329f42d4295989333f95f30a is a Shader.
So, perhaps this could be a possible cause? $$anonymous$$aybe you changed the type of a variable when you were editing away? If a prefab or scene used to reference a shader, that shader reference still exists in the scene or prefab file.
I appreciate you being patient with me and doing so much explaining. I think I found the problem. the albedo for a couple of my materials were sprites ins$$anonymous$$d of textures. I changed them so hopefully that does the trick.