private void DetectTexture(out long textureMemory,out int textureNum) { textureMemory = 0; textureNum = 0; var textures = Resources.FindObjectsOfTypeAll(typeof(Texture)); foreach (Texture t in textures) { if (t.hideFlags != HideFlags.None ) continue; textureNum++; long memoryUsed = Profiler.GetRuntimeMemorySizeLong(t); Debug.Log("Texture: " + t.name + ": Memory: " + (memoryUsed / 1000000f)); textureMemory += memoryUsed; } //Debug.LogError("texture num:"+tnum +" memory:"+ totalTextureMemorySize); //return totalTextureMemorySize; }
抓出的数据与Profiler/Memory/Assets/Texture/中数据基本吻合