示例#1
0
    public void CombineRender(MaterialAsset oOtherAsset)
    {
        if (this.oSelfAsset == null)
        {
            return;
        }
        MeshRenderer component = base.GetComponent <MeshRenderer>();

        if (component != null)
        {
            component.material = oOtherAsset.material;
            GameObjectUnit.ChangeShader(component);
        }
        MeshFilter component2 = base.GetComponent <MeshFilter>();

        if (component2 != null)
        {
            component2.mesh = this.oSelfAsset.mesh;
        }
        if (this.matchMono != null)
        {
            UnityEngine.Object.Destroy(this.matchMono);
        }
        UnityEngine.Object.Destroy(this);
    }
示例#2
0
    /// <summary>
    /// 根据设置更换合适的shader 和设置响应的阴影设置
    /// </summary>
    /// <param name="sRender"></param>
    public static void ChangeShader(Renderer sRender)
    {
        if (sRender == null || GameScene.mainScene == null)
        {
            return;
        }
        bool flag = false;

        if (sRender.gameObject.layer == GameLayer.Layer_Ground)            //只有地面接受阴影哦
        {
            sRender.receiveShadows = true;
        }
        else
        {
            sRender.receiveShadows = false;
            if (sRender.gameObject.layer == GameLayer.Layer_UIEffect)
            {
                flag = true;
            }
        }
        for (int i = 0; i < sRender.materials.Length; i++)
        {
            Material material = sRender.materials[i];
            if (!(material == null))
            {
                string a = material.shader.name;
                if (!GameScene.mainScene.terrainConfig.enablePointLight)
                {
                    if (a == GameObjectUnit.diffuseShaderName || a == GameObjectUnit.snailDiffusePointShaderName)
                    {
                        material.shader = GameObjectUnit.snailDiffuseShader;
                    }
                    if (a == GameObjectUnit.diffuseCutoutShaderName || a == GameObjectUnit.snailDiffusePointCutoutShaderName)
                    {
                        material.shader = GameObjectUnit.snailDiffuseCutoutShader;
                    }
                }
                else
                {
                    if (a == GameObjectUnit.diffuseShaderName || a == GameObjectUnit.snailDiffuseShaderName)
                    {
                        material.shader = GameObjectUnit.snailDiffusePointShader;
                    }
                    if (a == GameObjectUnit.diffuseCutoutShaderName || a == GameObjectUnit.snailDiffuseCutoutShaderName)
                    {
                        material.shader = GameObjectUnit.snailDiffusePointCutoutShader;
                    }
                }
                if (flag)
                {
                    GameObjectUnit.ChangeShader(material, new string[]
                    {
                        "Snail/Bumped Specular Point Light2",
                        "Snail/Bumped Specular Point Light Cutout2",
                        "Snail/Bumped Specular Point Light UV Anima2"
                    });
                }
            }
        }
    }
示例#3
0
 public void CombineRender(MeshAsset oOtherAsset)
 {
     if (this.oSelfAsset == null)
     {
         return;
     }
     if (this.matchMono is SkinMeshLoader)
     {
         SkinnedMeshRenderer component = base.GetComponent <SkinnedMeshRenderer>();
         if (component != null)
         {
             component.material   = this.oSelfAsset.material;
             component.sharedMesh = oOtherAsset.mesh;
             GameObjectUnit.ChangeShader(component);
         }
     }
     else if (this.matchMono is MeshLoader)
     {
         MeshRenderer component2 = base.GetComponent <MeshRenderer>();
         if (component2 != null)
         {
             component2.material = this.oSelfAsset.material;
             GameObjectUnit.ChangeShader(component2);
         }
         MeshFilter component3 = base.GetComponent <MeshFilter>();
         if (component3 != null)
         {
             component3.mesh = oOtherAsset.mesh;
         }
     }
     else if (this.matchMono == null)
     {
         MeshRenderer component4 = base.GetComponent <MeshRenderer>();
         if (component4 != null)
         {
             component4.material = this.oSelfAsset.material;
             GameObjectUnit.ChangeShader(component4);
         }
         else
         {
             SkinnedMeshRenderer component5 = base.GetComponent <SkinnedMeshRenderer>();
             if (component5 != null)
             {
                 component5.material = this.oSelfAsset.material;
                 GameObjectUnit.ChangeShader(component5);
             }
         }
     }
     if (this.matchMono != null)
     {
         UnityEngine.Object.Destroy(this.matchMono);
     }
     UnityEngine.Object.Destroy(this);
 }