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

Question dependence ScriptableObject load error.

Discussion in 'Asset Bundles' started by tangbinjielg, Oct 8, 2023.

  1. tangbinjielg

    tangbinjielg

    Joined:
    Oct 8, 2023
    Posts:
    1
    Bundle situation:
    1. Create a empty Project
    2. Create a prefab asset named soldier.prefab
    3. Create a ScriptableObject named SoldiersConfig, add [SerializeField] public int hp = 5;
    4. Create a MonoBehaviour Class named Soldiers, add public SoldiersConfig sc;
    5. Create a SoldiersConfig asset SoldiersConfig.asset
    6. soldier.prefab add Soldiers Component , Soldiers Component add SoldiersConfig.asset
    7. Build two bundle. One contain soldier.prefab. Another contain SoldiersConfig.asset.
    8. Create two button in scene Load and Unload

    load button event:
    1. Load two bundle if it not loaded.
    2. Load soldier.prefab asset.
    3. print hp in sc.

    unload button event:
    1.make sure NO Managed Object reference soldier.prefab asset (soldier.prefab not used).
    2. Unload the bundle contain SoldiersConfig.asset, NOT unload the bundle contain soldier.prefab.

    Running:
    1.press Load button, SoldiersConfig can be loaded. Got right result.
    2.press Unload button.
    3.press Load button again. got error:
    A scripted object (script unknown or not yet loaded) has a different serialization layout when loading.


    If dependence Asset is texture or material. it can be reload again when load prefab. why ScriptableObject can not?
     
  2. George-Ing

    George-Ing

    Unity Technologies

    Joined:
    Jan 14, 2020
    Posts:
    68
    Hey tangbinjielg,

    Certainly seems a bit weird - there are some difference between AssetBundles in the Editor and Player which may be a culprit. If you could submit a bug report then we'll get someone on the engineering team to look into it for you.