Search Unity

Question about Resources.Load

Discussion in 'Scripting' started by Alan-Liu, Jan 11, 2017.

  1. Alan-Liu

    Alan-Liu

    Joined:
    Jan 23, 2014
    Posts:
    393
    Does Resources.Load load all dependencies of an asset? For example, if I use Resources.Load to load a prefab which references some meshes, textures, particle systems etc, do these assets will be loaded simultaneously?
     
  2. Lethn

    Lethn

    Joined:
    May 18, 2015
    Posts:
    1,583
    If you only have one set of textures everything should load up including the children of the gameobject you are loading from the resources folder, however when you need to change the texture during runtime and load that in you'll have to use seperate code so the game engine knows that a change has been made.

    Just make sure that you've got everything you need in the resources folder as a prefab and it should all work. However if you're studying saving and loading something I learned was that if even the slightest thing changes in a gameobject you have to make sure that the game engine knows about it through code but if you're just purely loading up some prefabs from the resources folder you shouldn't have to worry too much about that.
     
  3. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Huh?

    Yes, the prefab is loaded in its entirety.
     
  4. Lethn

    Lethn

    Joined:
    May 18, 2015
    Posts:
    1,583
    Code (CSharp):
    1. Huh?
    Well that is if you're trying to get the game to remember everything about a gameobject in runtime :p just a simple resource.load is different though obviously, sorry should have been clearer.