Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Instantiated Gameobject have "Blank script" / weird behavior

Discussion in 'Addressables' started by GameMadeByGamers, Aug 23, 2022.

  1. GameMadeByGamers

    GameMadeByGamers

    Joined:
    Nov 25, 2014
    Posts:
    54
    I got weird behavior with my build, certain gameobject like the the one below have their script icon blank and dont initialize correctly (They act correctly if i instantiate them from a Gameobject field directly / without the addressable system).

    In this instance i load a scriptableobject containing the prefab i want to instantiate. (I did try to load the prefab directly but arrive to the same results)

    Unity version 2020.3.38f (LTS) , Addressable 1.18.9
    *Using Odin inspector



    How i load most of the asset :
    Code (CSharp):
    1.     public IEnumerator LoadAssetReference()
    2.     {
    3.         if (dataRef.Asset != null)
    4.         {
    5.             BattleEncounterData data = (BattleEncounterData)dataRef.Asset;
    6.             prefabTest = data.EnnemyAI;
    7.         }
    8.         else
    9.         {
    10.             AsyncOperationHandle<BattleEncounterData> encounterAsyncOp = dataRef.LoadAssetAsync<BattleEncounterData>();
    11.             yield return new WaitUntil(() => encounterAsyncOp.IsDone);
    12.             prefabTest = encounterAsyncOp.Result.EnnemyAI;
    13.         }
    14.     }
    The BattleEncounterData ScriptableObject :
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,843
    First thought, do you have addressables folders (ergo entire directories marked as addressable) with the affected scripts assets inside of them?

    If so, bring them outside of addressables scope, rebuild, and see how you go.
     
  3. GameMadeByGamers

    GameMadeByGamers

    Joined:
    Nov 25, 2014
    Posts:
    54
    No i dont have any folders marked as addressable.
     
  4. R1PFake

    R1PFake

    Joined:
    Aug 7, 2015
    Posts:
    507
    It looks the same for me, but everything still works fine on my end, so I never really researched it.

    Sorry for being off topic but I didn't know you can make a whole folder addressables without adding every object by hand o_O I will try that later, thanks for the hint
     
  5. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,843
    Yeah you can just select the folder in your project files; in the inspector there'll be a checkbox to make the folder addressable.

    I believe you can drag folders into your groups too.
     
  6. GameMadeByGamers

    GameMadeByGamers

    Joined:
    Nov 25, 2014
    Posts:
    54
    I will try upgrading the project to 2021 LTS so i can have a newer version of the Addressable packager, will update the post with the result.

    Update : No change will revert back to the previous version
     
    Last edited: Aug 25, 2022