Search Unity

Unable to read SubScenes data for Android with Entity 0.3.0.

Discussion in 'Entity Component System' started by Game_Rulez, Dec 4, 2019.

  1. Game_Rulez

    Game_Rulez

    Joined:
    May 28, 2019
    Posts:
    6
    After analyzing the problem, I found:
    1. During the build through ECS 0.3.0, all SubScenes are packaged and stored in Steaming Assets.
    2. After starting the application, the ResolveSceneReferenceSystem finds all requested SubScenes and creates the necessary Entities

    But there is a problem with reading this data on Android due to the inability to work with Steaming Assets through File.Exists / File.Open

    https://docs.unity3d.com/Manual/StreamingAssets.html
    https://answers.unity.com/questions/210909/android-streamingassets-file-access.html

    References to problems:
    • File.Exists(sceneHeaderPath) //ResolveSceneReferenceSystem.cs:121
    • File.Open(fileName, FileMode.Open, FileAccess.Read) //BinarySerialization.cs:99
    Problems part:

    In EntityScenesPaths:
    Code (CSharp):
    1. public static string GetLoadPath(Hash128 sceneGUID, PathType type, int sectionIndex)
    2. {
    3.     var extension = GetExtension(type);
    4.     if (type == PathType.EntitiesBinary)
    5.         return $"{Application.streamingAssetsPath}/SubScenes/{sceneGUID}.{sectionIndex}.{extension}";
    6.     else if (type == PathType.EntitiesHeader)
    7.         return $"{Application.streamingAssetsPath}/SubScenes/{sceneGUID}.{extension}";
    8.     else if (type == PathType.EntitiesUnityObjectReferences)
    9.         return $"{Application.streamingAssetsPath}/SubScenes/{sceneGUID}.{sectionIndex}.bundle";
    10.     else
    11.         return "";
    12. }
    In Unity.Scenes.Hybrid/ResolveSceneReferenceSystem.cs:119-136
    Code (CSharp):
    1. var sceneHeaderPath = EntityScenesPaths.GetLoadPath(scene.SceneGUID, EntityScenesPaths.PathType.EntitiesHeader, -1);
    2. #endif
    3. if (!File.Exists(sceneHeaderPath))
    4. {
    5.     #if UNITY_EDITOR
    6.     Debug.LogError($"Loading Entity Scene failed because the entity header file could not be found: {scene.SceneGUID}\n{sceneHeaderPath}");
    7.     #else
    8.     Debug.LogError($"Loading Entity Scene failed because the entity header file could not be found: {scene.SceneGUID}\nNOTE: In order to load SubScenes in the player you have to use the new BuildSettings asset based workflow to build & run your player.\n{sceneHeaderPath}");
    9.     #endif
    10.     return;
    11. }
    12. if (!BlobAssetReference<SceneMetaData>.TryRead(sceneHeaderPath, SceneMetaDataSerializeUtility.CurrentFileFormatVersion, out var sceneMetaDataRef))
    13. {
    14.     Debug.LogError("Loading Entity Scene failed because the entity header file was an old version: " + scene.SceneGUID);
    15.     return;
    16. }
    I apologize for any inaccuracies in Google Translate.
    I also noticed that ClassicBuildProfile.GetExecutableExtension () does not contain a handler for BuildTarget.iOS (Unity.Build.Common / Settings / ClassicBuildProfile.cs)
     
  2. Kmsxkuse

    Kmsxkuse

    Joined:
    Feb 15, 2019
    Posts:
    306
    A tad bit necromancy but I just wanted to say that you need to add the specific hardware Platforms package in order to build for that platform.

    For me it was
    com.unity.platforms.windows
    . Android will probably be something similar.