During my University third year, I was given the opportunity of creating a number of small research projects. During the third part of the year, I chose to create a custom profiler for the Unity engine.
The brief was that Unity's profiler is somewhat limited in what data it shows. It doesn't really give much in the way of helpful information such as the amount of memory an object is taking up. Thus, the task was to create a custom profiler which showed the memory usage of individual objects, including audio, meshes, textures, physics and scripts.
In many ways, I did just that, the profiler I created shows the memory usage of individual objects in a Unity scene. I had to use the old Unity Editor GUI functions to show this in an editor window utilising Unity's editor scripts. This meant I could create a window in the editor to run my profiler with, to incorporate it in any Unity project that I create.
The profiler shows the number of bytes of memory usage of each object in a hierarchy view not too dissimilar to the hierarchy view in Unity itself.
It is also shown in a bar graph and can also perform some limited analysis on objects in the scene to see if they are above a certain data threshold before reporting back with a warning message to the console to allow the user to track down problem objects.
The profiler does use some of Unity's internal functions, and one has to keep in mind that we just need to trust that they are doing the correct thing.
Unity also separates it's functionality in components, and as ingenious as this system is, it means that each Unity object doesn't contain much memory use. It just contains metadata. The components themselves are the things which take up the memory, and it is difficult to know if every component is being retrieved to create the total memory usage used. Unity uses, a lot of components after all.
Should you wish, please copy and paste the download link below. There you can download the project and inspect it yourself.
Unity version 5.3.2 required
https://drive.google.com/drive/folders/0B2-4-3Aj27LXM2g3R21mYkotdzQ?usp=sharing
No comments:
Post a Comment