Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Initial images loading issue

Discussion in 'Project Tiny' started by Seaqqull, Dec 7, 2020.

  1. Seaqqull

    Seaqqull

    Joined:
    Aug 3, 2018
    Posts:
    24
    When I upload my TinyProject on a dedicated server. After trying to open it loads and works just fine, but some images aren't loaded (When they actually in use on the scene).
    - Is there a way to check whether all assets (images) are loaded? so I would be able to simulate loading behaviour in the game and restrict player interaction with till all the assets will be downloaded by the client.
     
  2. AbdulAlgharbi

    AbdulAlgharbi

    Unity Technologies

    Joined:
    Jul 27, 2018
    Posts:
    319
    yes you can use the following system to check if the textures are loaded or not

    Code (CSharp):
    1.  
    2.  
    3. using Unity.Entities;
    4. using Unity.Tiny;
    5.  
    6. namespace TinyRacing.Systems
    7. {
    8.     [AlwaysUpdateSystem]
    9.     public class Loader:SystemBase
    10.     {
    11.         public bool IsReady;
    12.  
    13.         protected override void OnStartRunning()
    14.         {
    15.             base.OnStartRunning();
    16.             IsReady = false;
    17.         }
    18.  
    19.         protected override void OnUpdate()
    20.         {
    21.             if (IsReady)
    22.                 return;
    23.             Debug.Log("Loading...");
    24.             var loading = false;
    25.             Entities.WithAll<Image2DLoadFromFile>().ForEach((Entity e, ref Image2D img) =>
    26.             {
    27.                 if (img.status == ImageStatus.LoadError)
    28.                     Debug.Log("Error loading images");
    29.                 loading = true;
    30.             }).WithStructuralChanges().Run();
    31.             IsReady = !loading;
    32.  
    33.             if (IsReady)
    34.                 Debug.Log("Ready!");
    35.         }
    36.     }
    37. }
     
    xpxilom, Seaqqull and newguy123 like this.
  3. Seaqqull

    Seaqqull

    Joined:
    Aug 3, 2018
    Posts:
    24
    Thank you ^_^