1
\$\begingroup\$

I have came across a weird situation. I have a gameobject that has a standard shader material. The material rendering mode is set to Transparent. This is working fine in the Unity editor, but its transparency is not showing in the build mode.

Remember I am creating an asset bundle of the game objects. Then download it in the player. Yes, I know that the shader variant should be included in the build. So I have this standard shader in the build. On more thing I want to share is that I try to debug the player. Then, I found that the Keywords include only DIRECTIONAL LIGHTPROBE_SH while the same materail in the editor shows keyword DIRECTIONAL LIGHTPROBE_SH _ALPHABLEND_ON_EMISSION.

Remeber we are createing asset bundle in a seperate workspace while rendering the Asset bundle in a separate workspace. Here are the steps

  1. Imported the fbx in asset bundle creator workspace and export asset bundle from it.
  2. We have a seperate workspace that import the asset bundle on runtime.

Update: I fix this issue by when I instantiated the asset bundle I just enable the _ALPHABLEND_ON and _EMISSION keyworkds on the material. (check my answer) But i don't want this fix because it will add more time in overall asset bundle and downloading and instantaite process.

Update: I found that i am creating asset bundle in a seperate workspace and loading it in a different workspace. If i am making the bundle in the scene workspace then, it work fine. But why? How to resolve this?

\$\endgroup\$
4
  • \$\begingroup\$ Let's try to eliminate possible contributing factors. Can you reproduce this problem in a new, empty project, one that does not use asset bundles? If asset bundles are required to reproduce the issue, walk us through the steps to create a minimal bundle and build that demonstrates the problem. \$\endgroup\$
    – DMGregory
    May 10, 2023 at 12:01
  • \$\begingroup\$ Asset bundles are created in a separate workspace while the bundles are loading in another workspace. If i use the same gameobject in the same workspace without asset bundle then, that gameobject rendering fine in the build as well. But the same object is not render with transparency. Desipte both use same shader variant \$\endgroup\$ May 10, 2023 at 12:26
  • \$\begingroup\$ Great, it sounds like you've identified the steps to create a Minimal Complete Verifiable Example. Edit your question to walk us through the steps we should follow, starting from the New Project wizard, to arrive at a reproduction of this issue. \$\endgroup\$
    – DMGregory
    May 10, 2023 at 12:27
  • \$\begingroup\$ You still haven't walked us through the complete steps to set up these "workspaces" you keep referring to and produce an asset bundle that demonstrates the problem. You won't get answers until users can reproduce the exact situation you're dealing with. \$\endgroup\$
    – DMGregory
    May 15, 2023 at 11:00

1 Answer 1

0
\$\begingroup\$

I fixed this issue by enabling the _ALPHABLEND_ON and _EMISSION keywords on the material when I instantiated the asset bundle.

private void MaterialSettings(GameObject go)
    {
        Renderer[] renderers = go.GetComponentsInChildren<Renderer>();
        foreach (Renderer renderer in renderers)
        {
            foreach (Material material in renderer.sharedMaterials)
            {
                ApplyTransparency(material);
            }
        }
    }

    private static void ApplyTransparency(Material material)
    {
       
        material.EnableKeyword("_EMISSION");
        material.EnableKeyword("_ALPHABLEND_ON");
       
    }

However, I do not want to use this fix because it will increase the overall time required for downloading and instantiating the asset bundle.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .