Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Want to make a dictionary that could be set in the most efficient way

Discussion in 'Scripting' started by Cedrus97, Jul 8, 2020.

  1. Cedrus97

    Cedrus97

    Joined:
    Jul 12, 2019
    Posts:
    16
    I want to have a dictionary of dictionaries that will contain animators. The this is, those are not supposed to ever change so I was hoping that I could make the dictionaries be pre-made or in any other way make them power-efficient.

    If anyone could give me ideas I would very much appreciate it.
    Thanks in advance
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    2,369
    In terms of power efficiency, as long as you're only writing to the dictionary once over the course of the application lifetime it probably doesn't matter when you create the objects. You will need to do the same amount of work no matter what.
     
  3. Cedrus97

    Cedrus97

    Joined:
    Jul 12, 2019
    Posts:
    16
    True, however, I do not see a reason why I should set the dictionary every time I boot the system. I have no understanding of the subject but it seems like something that would just make the initial booting longer. Is there no way to avoid it?
     
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    2,369
    If you want to use the data in your program it has to be loaded into memory. There is no way around this. One thing you can do is something called lazy loading where you only load the data into memory when you actually need it. The benefit of this is that if you never end up using the data you don't waste time loading it. The drawback is that if loading is slow you may end up loading at a time that is inconvenient for the user resulting in a bad experience.

    If you only need bits and pieces of the data at a time you can keep it in separate files/assets and only load it in little chunks as needed. It really depends on the nature of your data and your expected access patterns over the course of your game.
     
  5. Cedrus97

    Cedrus97

    Joined:
    Jul 12, 2019
    Posts:
    16
    Thank you for the advice. I will try and see what suits my needs.
     
unityunity