Cocos Creator v2.1.2. No builtin materials after building for `Web Mobile` platform

Cocos Creator v2.1.2. No builtin materials after building for `Web Mobile` platform
0

Hi, everyone.
I am trying to switch from v2.1.0 to v2.1.2
Game works when running from editor. But when I built for Web Mobile platform I’ve got an error:

CCMaterial.js:120 Uncaught TypeError: Cannot read property '_owner' of undefined
    at Function.getInstantiatedMaterial (CCMaterial.js:120)
    at CCClass.293.GraySpriteState._switchGrayMaterial (gray-sprite-state.js:31)
    at CCClass._updateDisabledState (CCButton.js:857)
    at CCClass._updateState (CCButton.js:736)
    at CCClass.__preload (CCButton.js:426)
    at CCClass.eval [as _invoke] (eval at createInvokeImpl (component-scheduler.js:256), <anonymous>:3:65)
    at CCClass.invoke (node-activator.js:66)
    at CCClass.activateNode (node-activator.js:227)
    at CCClass._onHierarchyChanged (base-node.js:1171)
    at CCClass._onHierarchyChanged (CCNode.js:1304)

After debugging I found out that problem is with builtin materials loading. AssetLibrary._loadBuiltins doesn’t load any material.

Did anyone have similar problem?

I had the same problem upgrading to v2.2.0 from v2.0.9, and turns out my build-template for the main.js file was causing issues, since this is where cc.AssetLibrary is initialized. I removed the template for 2.0.9, rebuilt, and added in the parts I needed for a new template, and now everything works fine :slightly_smiling_face:

It took me a long time to realize the source of this issue; hope this helps save time for some others.

1 Like