DetectLeaks

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(Removing all content from page)
m (Reverted edits by Joseph05408 (Talk); changed back to last version by Eric5h5)
Line 1: Line 1:
 +
[[Category: Debugging Scripts]]
 +
[[Category: Heads Up Display Scripts]]
 +
[[Category: C Sharp]]
 +
[[Category: MonoBehaviour]]
 +
Author: Joachim Ante
  
 +
== Description ==
 +
This script will displays the number of alloctated unity objects by type. This is useful for finding leaks.
 +
Knowing the type of object (mesh, texture, sound clip, game object) that is getting leaked is the first step.
 +
You could then print the names of all leaked assets of that type.
 +
 +
 +
== C# - DetectLeaks ==
 +
The script _must_ be named DetectLeaks.cs
 +
<csharp>
 +
using UnityEngine;
 +
using System.Collections;
 +
 +
public class DetectLeaks : MonoBehaviour {
 +
 +
void OnGUI () {
 +
GUILayout.Label("All " + FindObjectsOfTypeAll(typeof(UnityEngine.Object)).Length);
 +
GUILayout.Label("Textures " + FindObjectsOfTypeAll(typeof(Texture)).Length);
 +
GUILayout.Label("AudioClips " + FindObjectsOfTypeAll(typeof(AudioClip)).Length);
 +
GUILayout.Label("Meshes " + FindObjectsOfTypeAll(typeof(Mesh)).Length);
 +
GUILayout.Label("Materials " + FindObjectsOfTypeAll(typeof(Material)).Length);
 +
GUILayout.Label("GameObjects " + FindObjectsOfTypeAll(typeof(GameObject)).Length);
 +
GUILayout.Label("Components " + FindObjectsOfTypeAll(typeof(Component)).Length);
 +
}
 +
}
 +
</csharp>

Revision as of 19:16, 19 October 2009

Author: Joachim Ante

Description

This script will displays the number of alloctated unity objects by type. This is useful for finding leaks. Knowing the type of object (mesh, texture, sound clip, game object) that is getting leaked is the first step. You could then print the names of all leaked assets of that type.


C# - DetectLeaks

The script _must_ be named DetectLeaks.cs <csharp> using UnityEngine; using System.Collections;

public class DetectLeaks : MonoBehaviour {

void OnGUI () { GUILayout.Label("All " + FindObjectsOfTypeAll(typeof(UnityEngine.Object)).Length); GUILayout.Label("Textures " + FindObjectsOfTypeAll(typeof(Texture)).Length); GUILayout.Label("AudioClips " + FindObjectsOfTypeAll(typeof(AudioClip)).Length); GUILayout.Label("Meshes " + FindObjectsOfTypeAll(typeof(Mesh)).Length); GUILayout.Label("Materials " + FindObjectsOfTypeAll(typeof(Material)).Length); GUILayout.Label("GameObjects " + FindObjectsOfTypeAll(typeof(GameObject)).Length); GUILayout.Label("Components " + FindObjectsOfTypeAll(typeof(Component)).Length); } } </csharp>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox