Beispiel #1
0
 private void Awake()
 {
     if (Application.isPlaying)
     {
         CustomPlayerLoop.Init();
     }
 }
Beispiel #2
0
        private void UpdateMainThreadMeter()
        {
            float allTime          = CustomPlayerLoop.GetLastExecuteTime();
            float scriptUpdateTime = CustomPlayerLoop.GetProfilingTime <Update.ScriptRunBehaviourUpdate>() +
                                     CustomPlayerLoop.GetProfilingTime <PreLateUpdate.ScriptRunBehaviourLateUpdate>() +
                                     CustomPlayerLoop.GetProfilingTime <FixedUpdate.ScriptRunBehaviourFixedUpdate>() +
                                     CustomPlayerLoop.GetProfilingTime <Update.ScriptRunDelayedDynamicFrameRate>();
            float animatorTime = CustomPlayerLoop.GetProfilingTime <PreLateUpdate.DirectorUpdateAnimationBegin>() +
                                 CustomPlayerLoop.GetProfilingTime <PreLateUpdate.DirectorUpdateAnimationEnd>();
            float renderTime  = CustomPlayerLoop.GetProfilingTime <PostLateUpdate.FinishFrameRendering>();
            float physicsTime = CustomPlayerLoop.GetProfilingTime <FixedUpdate.PhysicsFixedUpdate>();

            // for android multiThread
#if UNITY_ANDROID && !UNITY_EDITOR
            if (SystemInfo.graphicsMultiThreaded)
            {
                float waitForGfxPresent = CustomPlayerLoop.GetGfxWaitForPresent();
                renderTime -= waitForGfxPresent;
                allTime    -= waitForGfxPresent;
            }
#endif
            float otherTime = allTime - scriptUpdateTime - animatorTime - renderTime - physicsTime;


            mainThreadMeter.SetParameter(MeterIdxScript, scriptUpdateTime / this.expectedExecuteTime);
            mainThreadMeter.SetParameter(MeterIdxAnimator, animatorTime / this.expectedExecuteTime);
            mainThreadMeter.SetParameter(MeterIdxRendeing, renderTime / this.expectedExecuteTime);
            mainThreadMeter.SetParameter(MeterIdxPhysics, physicsTime / this.expectedExecuteTime);
            mainThreadMeter.SetParameter(MeterIdxOther, otherTime / this.expectedExecuteTime);
        }
Beispiel #3
0
        private void UpdateRenderThreadMeter()
        {
            if (!SystemInfo.graphicsMultiThreaded)
            {
                return;
            }
            if (recordCamerRender == null)
            {
                recordCamerRender = Recorder.Get("Camera.Render");
            }
            float cameraRenderTime = recordCamerRender.elapsedNanoseconds * 0.000000001f;
            float mainThreadTime   = CustomPlayerLoop.GetProfilingTime <PostLateUpdate.FinishFrameRendering>();

#if UNITY_ANDROID && !UNITY_EDITOR
            float waitForGfxPresent = CustomPlayerLoop.GetGfxWaitForPresent();
            mainThreadTime -= waitForGfxPresent;
#endif
            float renderThreadTime = cameraRenderTime - mainThreadTime;
            renderThreadMeter.SetParameter(0, renderThreadTime / this.expectedExecuteTime);
        }
Beispiel #4
0
        // Update is called once per frame
        private void Update()
        {
            UpdateExpectedExecuteTime();
            UpdateMainThreadMeter();
#if DEBUG || DEVELOPMENT_BUILD
            UpdateRenderThreadMeter();
#endif
            int sec = (int)Time.realtimeSinceStartup;

            float allTime = CustomPlayerLoop.GetLastExecuteTime();
            // for android multiThread
#if UNITY_ANDROID && !UNITY_EDITOR
            if (SystemInfo.graphicsMultiThreaded)
            {
                float waitForGfxPresent = CustomPlayerLoop.GetGfxWaitForPresent();
                allTime -= waitForGfxPresent;
            }
#endif
            AppendExecuteTime(allTime);
            if (this.currentStartSec != sec)
            {
                stringBuilderBuffer.Length = 0;
                stringBuilderBuffer.Append("FPS:").Append(this.sumCount).Append(" ");
                stringBuilderBuffer.Append("(Avg:")
                .AddMsecFromSec(this.sumExecuteTime / (float)this.sumCount)
                .Append("ms)\n");

                stringBuilderBuffer.Append("min-max:")
                .AddMsecFromSec(this.minExecuteTime)
                .Append("ms");

                stringBuilderBuffer.Append(" - ")
                .AddMsecFromSec(this.maxExecuteTime)
                .Append("ms");

                frameRateText.text = stringBuilderBuffer.ToString();
                this.GotoNextSec(sec);
            }
        }
Beispiel #5
0
 void OnPreCull()
 {
     CustomPlayerLoop.OnPreCulling();
 }