Unity5.x 加载Assetbundle shader丢失问题记录


1、场景中模型的shader丢失

借用网上的诸多方法,将用到的shader 加入到 菜单 Editor => ProjectSettings => GraphicsSettings =>AlwaysIncludeShaders


2、NGUI 图集 shader丢失问题

重新设置NUGI的 shader

举例子

UISprite.cs 中,红色字体为重新赋值Shader,问题得到解决


    public void ShowAsWhiteBlack(bool show, bool isDebugShow = false)
    {
        if (show)
        {
            if (MogoMaterial == null)
            {
                //Material mat = new Material(Shader.Find("Mogo/BlackWhite"));
                //Material mat = Resources.Load("MogoBlackWhiteMat") as Material;
                //mat.mainTexture = material.mainTexture;
                //MogoMaterial = mat;

                Material mat = new Material(Shader.Find("Mogo/BlackWhiteETC"));
                mat.mainTexture = material.mainTexture;
                mat.SetTexture("_AlphaTex", material.GetTexture("_AlphaTex"));

                m_oriTex = material.mainTexture;
                m_oriAlphaTex = material.GetTexture("_AlphaTex");

                MogoMaterial = mat;

                if (!isDebugShow)
                {
                    RefreshPanel(gameObject);
                }

                //AssetCacheMgr.GetUIResource("MogoBlackWhiteMat.mat", (go) =>
                //{
                //    Material mat = go as Material;

                //    mat.mainTexture = material.mainTexture;
                //    mat.SetTexture("_AlphaTex", material.GetTexture("_AlphaTex"));

                //    m_oriTex = material.mainTexture;
                //    m_oriAlphaTex = material.GetTexture("_AlphaTex");

                //    //Debug.LogError("Here");
                //    MogoMaterial = mat;

                //    if (!isDebugShow)
                //    {
                //        RefreshPanel(gameObject);
                //    }
                //});
            }
            else
            {
                MogoMaterial.mainTexture = m_oriTex;
                MogoMaterial.SetTexture("_AlphaTex", m_oriAlphaTex);
                if (!isDebugShow)
                {
                    RefreshPanel(gameObject);
                }
            }
        }
        else
        {
            MogoMaterial = null;
            RefreshPanel(gameObject);
        }
        MogoMaterial.shader = Shader.Find(MogoMaterial.shader.name);
    }

3、人物模型shader丢失问题


获取到人物 上的SkinnedMeshReanderer 修改为 material.shader = Shader.Find(MogoMateial.shader.name 问题得到解决


唉unity 坑坑坑!!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值