Search Unity

Optimization for android

Discussion in 'Android' started by nail_safin, Sep 3, 2017.

  1. nail_safin

    nail_safin

    Joined:
    Oct 31, 2016
    Posts:
    14
    Hello!

    I have a couple of optimization questions. I want to make out an example of my app. My app have a static class of inventory. In this class awake method is initializing the data.

    // field in my inventory class
    Code (csharp):
    1.  
    2. public static Item item;
    3.  
    // init in awake method in inventory class
    Code (csharp):
    1.  
    2. item = new Item("Name", "MaterialName");
    3.  
    // item class
    Code (csharp):
    1.  
    2. [System.Serializable]
    3. public class Item
    4. {
    5.        public string name;
    6.        public Material materialName;
    7.  
    8.        public Item(string name, string materialName)
    9.        {
    10.               this.name= name;
    11.               this.materialName= Resources.Load("Materials/Items/" + materialName) as Material;
    12.  
    13.               Inventory.instance.AddToItemRegistery(this);
    14.        }
    15. }
    16.  
    The copy of every item always is located in memory and i think it's can cause crashes on some devices. I have >60 items. Each item contains material and each material contain aldebo texture, metall map and normal map. Some people says that game crash and i think this inventory system may be a problem. I think that i need to hold only material name in the item class. Only when i need to use material i should make GetMaterial function that will load material by name in run time. Also i can make only one material and change textures in run time. What is way will be best for performance?

    Also I have a lot of textures. Different profiles. Albedo, metal and normal maps. I can not keep them in the atlas maps, so I think that they need to be compressed. But I do not know how to do it better. I want to hear your opinion so.