LoginSignup
0
0

More than 5 years have passed since last update.

UnityのProfilerDriverでよく使うものの紹介

Posted at

概要

UnityのProfilerの情報を取得したり設定したりするときに避けては通れないProfilerDriver。
ただUnityEditorInternalに入ってるだけにどこかに使い方がまとまってたりするわけではないので、軽くよく使う項目をまとめてみました。
だいたいのことはコードに入ってるので興味ある人は覗いてみてください

動作環境
Unity 2018.1.4f1

サンプルコードのリポジトリ
UnitySandbox/ProfilerDriverSample.cs
https://github.com/KTA552/UnitySandbox/blob/develop/UnitySandbox/Assets/Scripts/Debug/ProfilerDriverSample.cs

サンプルコード


            using (new EditorGUILayout.VerticalScope())
            {
                EditorGUILayout.Space();

                EditorGUI.BeginDisabledGroup(true);

                // Profilerで選択されている関数のパスを取得
                var selectPath = ProfilerDriver.selectedPropertyPath;
                if (selectPath == string.Empty) selectPath = "not selected.";

                EditorGUILayout.LabelField("selectedPropertyPath", selectPath);

                // Profilerで計測している開始と最後のフレーム数
                var firstFrame = ProfilerDriver.firstFrameIndex;
                var lastFrame = ProfilerDriver.lastFrameIndex;

                EditorGUILayout.IntField("firstFrameIndex", firstFrame);
                EditorGUILayout.IntField("lastFrameIndex", lastFrame);

                // 計測対象がEditorかどうか
                var isProfileEditor = ProfilerDriver.profileEditor;

                // DeepProfileをしているかどうか
                var isDeepProfile = ProfilerDriver.deepProfiling;

                EditorGUILayout.Toggle("profileEditor", isProfileEditor);
                EditorGUILayout.Toggle("deepProfiling", isDeepProfile);

                var connectedProfilerCount = ProfilerDriver.connectedProfiler;
                EditorGUILayout.IntField("connectedProfiler", connectedProfilerCount);

                EditorGUI.EndDisabledGroup();

                // Profilerの中の情報をクリア
                if (GUILayout.Button("ClearAllFrames"))
                {
                    ProfilerDriver.ClearAllFrames();
                }
            }



0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0