用户工具

站点工具


侧边栏

script:unityengine:classes:profiler:profiler.getruntimememorysize

Profiler.GetRuntimeMemorySize 获取运行时内存大小

JavaScript ⇒ public static function GetRuntimeMemorySize(o: Object): int;
C# ⇒ public static int GetRuntimeMemorySize(Object o);

Parameters 参数

Description 描述

Returns the runtime memory usage of the resource.

返回运行时,资源使用的内存。

This has been implemented for the following resource types: Mesh, Texture, Audio, Animation and Materials Only available in development players and editor.

这被应用于下列资源类型:网格,纹理,音效,动画和材质就,仅在开发对象和编辑器中可获取。

JavaScript:

	// Search for any object of Type Texture
	// if found print its name and memory usaage, else print a message
	// that says that it was not found.
	function Update() {
		#if ENABLE_PROFILER
		var textures = Resources.FindObjectsOfTypeAll(typeof(Texture));
		foreach(Texture t in textures)
			Debug.Log("Texture object " + t.name + " using: " + Profiler.GetRuntimeMemorySize(t) + "Bytes");
		#endif
	}

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour
{
	public GameObject respawnPrefab;
	public GameObject respawn;
	// Search for any object of Type Texture
	// if found print its name and memory usaage, else print a message
	// that says that it was not found.
	void Update()
	{
#if ENABLE_PROFILER
		var textures = Resources.FindObjectsOfTypeAll(typeof(Texture));
		foreach(Texture t in textures)
			Debug.Log("Texture object " + t.name + " using: " + Profiler.GetRuntimeMemorySize(t) + "Bytes");
#endif
	}
}

profiler

script/unityengine/classes/profiler/profiler.getruntimememorysize.txt · 最后更改: 2016/08/02 05:37 (外部编辑)