Search Unity

Materials unlinked from GameObject in packed mode

Discussion in 'Addressables' started by 5argon, Oct 4, 2018.

  1. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    I used Addressables.Instantiate<GameObect>("go") and I am able to instantiate it in play mode as "packed mode". However the material turns to pink. (Fast and virtual mode does not turns to pink)

    When I click (it does not ping the material in my project, indicating that it is from a packed mode), replace it with an equivalent material in the project it now looks correct.

    In the Addressables panel, there is only the GameObject addressed as "go" and no any other assets that the GameObject used. It seems to be able to understand and dragged textures and scripts to the Addressables except these unlinked materials. Is there any other procedure I should do to enable embeded materials in the game object?

    Screenshot 2018-10-04 20.24.07.png

    In build output preview I also find the material inside

    Screenshot 2018-10-04 20.44.10.png
     
    Last edited: Oct 5, 2018
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
    I think problem not in material but in shader reference.
     
  3. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    I tried logging the loaded shader inside the packed material (A built-in UI/Default material)

    Debug.Log($"{image.material.shader.name}");
    Debug.Log($"{image.material.shader.isSupported}");
    Debug.Log($"{image.material.shader.renderQueue}");

    UI/Default
    False
    2000

    But when I replace it mid-play mode with the project's copy of the same material

    UI/Default
    True
    3000

    Seems like it is not packing the correct variant?
     
  4. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
    It looks like, I think we must wait someone from Unity stuff for clear explanation :)

    P.S. And you traitor, threw our warm ECS branch :D
     
  5. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    I understand now, it works in the phone.

    Because I am on Android build, the packed material's shader was converted to Android-compatible (OpenGLES), it is now not render properly in the macOS editor (Metal?) anymore. (If this is the case then this "packed mode in editor" button is not useful...)

    (Love to get my project to bleeding-edge everything!)
     
    Deleted User and eizenhorn like this.
  6. Deleted User

    Deleted User

    Guest

    Hi there. A bit of off-topic. Don't you know is there any way to load assets by Hash128 or GUID instead of just a name?
     
  7. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    Hi, Hash128 of a GUID already works with
    LoadAsset(key)
    . Because the ResourceLocationMap (one of your available Addressables.ResourceLocator) derive 2 dictionary entries from one row of item dragged into Addressables panel : by string and by Hash128.

    Code (CSharp):
    1.             //var asyncOp = Addressables.LoadAsset<SpriteAtlas>("ATL");
    2.             var asyncOp = Addressables.LoadAsset<SpriteAtlas>(Hash128.Parse("a75e8e5a8966f40dd98c262581be0122"));
    3.             asyncOp.Completed += ops =>
    4.             {
    5.                 SpriteAtlas atlas = ops.Result;
    6.                 sprites = new Sprite[atlas.spriteCount];
    7.                 atlas.GetSprites(sprites);
    8.                 //Debug.Log($"Done {atlas.spriteCount}");
    9.             };
    Screenshot 2018-10-05 11.03.09.png
     
    Deleted User likes this.
  8. Deleted User

    Deleted User

    Guest

    You are my hero. Thank you so much.
    Last question, is there any way to prevent Bundles compilation every time on standalone build, even though there is no changes?
     
  9. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    I think I don't know about the build process yet, but in v0.4.0 there is a relevant entry in the change log that might be worth looking for. Maybe this "buildscript" is responsible for it?

    Screenshot 2018-10-05 11.46.53.png
     
    Deleted User likes this.
  10. Deleted User

    Deleted User

    Guest

    Hi there.

    Could you help me? How did can I get addressable asset hash to send it over the network?

    Edit:

    Should check Addressables.ResourceLocators.
    Thank you.
     
    Last edited by a moderator: Oct 7, 2018
  11. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    973
    Yeah, to test in editor the asset bundles used must be for the platform the Editor is running on, as the data used is *exactly* what is in the bundle, without any of the Editor magic that normally occurs. It's annoying, we have the same issue, but it is what it is. I am not sure what they could do about that to be honest.