Search Unity

Bug No VFX in game

Discussion in 'Visual Effect Graph' started by Berens_mds, Feb 16, 2023.

  1. Berens_mds

    Berens_mds

    Joined:
    Mar 10, 2020
    Posts:
    12
    Hi,

    Our VFX are sometimes missing in our game. It seems to be random, sometime we got them and sometime we don't... So far we noticed :
    - Recompiling the VFX seems to fix the issue for a time as it is relinking some properties. But doing so for 500 VFX increase our build time from 3h to 10h
    - Just reimporting with AssetDatabase can fix the issue sometime but also increase our build time too significantly to be part of our build process.
    - In both ways, fixing the issue doesn't change any file on disk and thus, the fix cannot be shared with the rest of the team.

    The prefab referencing the VisualEffectAsset are explicitly addressables, but the vfxs are not.

    Any help would be appreciated.
     
  2. Berens_mds

    Berens_mds

    Joined:
    Mar 10, 2020
    Posts:
    12
    So in case anyone else is struggling with this too, we managed to fix the issue by launching Unity, reimporting all VisualEffectAssets on the project then close the editor before the actual build process (which opens Unity again and runs various tasks).
    Now we have all our VFXs in the game and we are only loosing about 5 - 10 minutes in the process.
    We, however, still don't understand why we have to do that for every build.
     
  3. qiuji10

    qiuji10

    Joined:
    Feb 13, 2022
    Posts:
    6

    hi may i know how do you reimporting all VisualEffectAssets? is it just cut from folder and paste to the same place again? or through other kind of ways?
     
  4. Berens_mds

    Berens_mds

    Joined:
    Mar 10, 2020
    Posts:
    12
    @qiuji10 We made this script that we call before doing our builds.

    Code (CSharp):
    1.            string[] vfxGuids;
    2.             int i = 0;
    3.  
    4.             try
    5.             {
    6.                 AssetDatabase.StartAssetEditing();
    7.                 vfxGuids = AssetDatabase.FindAssets($"t:VisualEffectAsset");
    8.                 for (; i < vfxGuids.Length; ++i)
    9.                 {
    10.                     string guid = vfxGuids[i];
    11.                     string path = AssetDatabase.GUIDToAssetPath(guid);
    12.  
    13.                     try
    14.                     {
    15.                         AssetDatabase.ImportAsset(path);
    16.                     }
    17.                     catch (Exception ex)
    18.                     {
    19.                         Debug.LogError($"VFXImportException at path {path} :\n{ex}");
    20.                         continue;
    21.                     }
    22.                     Write($"VFXImport done for '{path}' ({i}/{vfxGuids.Length}).");
    23.                 }
    24.  
    25.                 Log($"{i} VFXs reimported.");
    26.             }
    27.             catch (Exception e)
    28.             {
    29.                 LogError("VFXImportException : " + e);
    30.             }
    31.             finally
    32.             {
    33.                 AssetDatabase.StopAssetEditing();
    34.             }
     
    qiuji10 likes this.
  5. qiuji10

    qiuji10

    Joined:
    Feb 13, 2022
    Posts:
    6
    Thanks!