概要
using System.Collections;
using Unity.EditorCoroutines.Editor;
using UnityEditor;
using UnityEngine;
public sealed class Example : EditorWindow
{
[MenuItem( "Tools/Open" )]
private static void Open()
{
GetWindow<Example>();
}
private void OnGUI()
{
if ( GUILayout.Button( "開始" ) )
{
EditorCoroutineUtility.StartCoroutine( OnUpdate(), this );
}
}
private static IEnumerator OnUpdate()
{
const int count = 2000;
var id = Progress.Start
(
name: "ここにタスク名",
description: "ここに説明"
);
for ( var i = 0; i < count; i++ )
{
Progress.Report
(
id: id,
currentStep: i,
totalSteps: count,
description: $"{i + 1} / {count}"
);
yield return null;
}
Progress.Remove( id );
}
}