Profiling.Profiler.GetRuntimeMemorySizeLong

Unity · Версия 2020.3 LTS · Scripting · Profiler

Profiling.Profiler.GetRuntimeMemorySizeLong

Объявление

public static long GetRuntimeMemorySizeLong(Object o);

Параметры

o Целевой объект Unity.

Возвращает

long Объем собственной памяти, используемой объектом Unity. Это возвращает 0, если Profiler недоступен.

Описание

Собирает внутреннюю память, используемую объектом Unity.

using UnityEngine;
using System.Collections;
using UnityEngine.Profiling;

public class ExampleClass : MonoBehaviour
{
    void Update()
    {
        Object[] textures = Resources.FindObjectsOfTypeAll(typeof(Texture));
        foreach (Texture t in textures)
        {
            Debug.Log("Texture object " + t.name + " using: " + Profiler.GetRuntimeMemorySizeLong((Texture)t) + "Bytes");
        }
    }
}

Обновлено 17 ноября 2026 г.