About the Assetbundle,shader lost problem

Source: Internet
Author: User

Starting with Unity4.2, in order to reduce the first packet size, all shader engines are not added to the game program by default, and unity will pack the shader engine into the assetbundle resources, as unity Support says, but I can't find it in my test (maybe I'm not opening it ... ), but just add the shader to Editor->graphics settings's shader list and pack.

Straight to the point, Unity's assetbundle is the way to manage resources, but there will be some attention to the specific packaging of the use of a detailed look at Unity Assetbundle Crawl Pit notes. Here's a question on mobile devices that depends on packaging:

When the dependency is packaged, it is missing when loading, but the mapping information is still there.


In the discovery of shader, he made a mistake.


The current mistake is to use Unity's unlit/transparent cutout, usually our solution is, in Add the shader to the shader list of editor->graphics settings and then use the following script to fix it:

public class Fixshader:monobehaviour {private list<material> thismaterial;     Private list<string> shaders;        void Start () {thismaterial = new list<material> (6);        Shaders = new list<string> (6);        meshrenderer[] Meshrenderer = getcomponentsinchildren<meshrenderer> ();        int length = Meshrenderer.length; for (int i = 0; i < length; i++) {int count = Meshrenderer[i].materials.            Length;                for (int j = 0; J < Count; J + +) {Material _mater = meshrenderer[i].materials[j];                Thismaterial.add (_mater); Shaders.            ADD (_mater.shader.name);        }} skinnedmeshrenderer[] Meshskinrenderer = getcomponentsinchildren<skinnedmeshrenderer> ();        length = Meshskinrenderer.length; for (int i = 0; i < length; i++) {int count = Meshskinrenderer[i].materials.            Length; for (int j = 0; J < Count                J + +) {Material _mater = meshskinrenderer[i].materials[j];                Thismaterial.add (_mater); Shaders.            ADD (_mater.shader.name); }} for (int i = 0; i < Thismaterial.count; i++) {Thismaterial[i].shader = Shad Er.        Find (Shaders[i]); }    }}
This solves the loss problem, but when you write a shader yourself, or use a shader, you can't always use it every time.editor->graphics settings to add shader, and then in the contract. If you do not add or forget to add, the post will still be lost after the mobile device.

The solution to the editor's shader is

< Span style= "Color:rgb (54,46,43); Font-family:verdana,arial,helvetica,sans-serif; font-size:14.44444465637207px; line-height:20.98958396911621px ">1. Dependent packaging
2.shader to the Resources folder, must be resources folder.


If there are any irregularities, please add the advice.





Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

About the Assetbundle,shader lost problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.