版本:Unity 6(6000.0)
语言简体中文
  • C#

ProfilerFlowEventType.End

建议更改

提交成功!

感谢你帮助我们提高 Unity 文档质量。尽管我们无法接受所有意见,但我们会阅读每个用户建议的更改,并酌情进行更新。

关闭

提交失败

由于某些原因导致你的建议更改无法提交。请在几分钟后<a>重试</a>。感谢你花时间帮助我们改进 Unity 文档的质量。

关闭

取消

描述

用于流程结束点。

将包含 ProfilerFlowEventType.End 的 ProfilerMarker 范围标记为最终流程点。

using System;
using System.Threading;
using Unity.Profiling;
using Unity.Profiling.LowLevel;
using Unity.Profiling.LowLevel.Unsafe;

public class Example { public const int k_NumberOfTasks = 4;

static readonly ProfilerMarker k_ScheduleParallelTasksMarker = new ProfilerMarker("Schedule Parallel Tasks"); static readonly ProfilerMarker k_ParallelTaskMarker = new ProfilerMarker("Parallel Task"); static readonly ProfilerMarker k_TaskSyncMarker = new ProfilerMarker("Sync Task");

static void EmitFlowEventAndChainThread(uint flowId) { // Mark the next k_ParallelTaskMarker as a beginning of the flow ProfilerUnsafeUtility.FlowEvent(flowId, ProfilerFlowEventType.ParallelNext); using (k_ParallelTaskMarker.Auto()) { // Do work } }

static void ScheduleParallelTask() { uint flowId; var threads = new Thread[k_NumberOfTasks]; using (k_ScheduleParallelTasksMarker.Auto()) { flowId = ProfilerUnsafeUtility.CreateFlow(ProfilerUnsafeUtility.CategoryScripts); // Mark the parent k_ScheduleParallelTasksMarker as a beginning of the flow ProfilerUnsafeUtility.FlowEvent(flowId, ProfilerFlowEventType.Begin); for (var i = 0; i < k_NumberOfTasks; ++i) { var thread = new Thread(() => EmitFlowEventAndChainThread(flowId)); thread.Start(); threads[i] = thread; } }

using (k_TaskSyncMarker.Auto()) { // Mark the parent k_TaskSyncMarker as a beginning of the flow ProfilerUnsafeUtility.FlowEvent(flowId, ProfilerFlowEventType.End); for (var i = 0; i < k_NumberOfTasks; ++i) threads[i].Join(); } } }