Initial commit

This commit is contained in:
2026-03-03 00:39:30 +05:00
commit fc01f07d9b
29933 changed files with 5353098 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
using System;
using UnityEditor;
namespace Unity.PlasticSCM.Editor.UI
{
internal class DelayedActionByFramesRunner
{
internal static bool IsUnitTesting { get; set; }
internal bool IsRunning { get { return mIsOnDelay; } }
internal DelayedActionByFramesRunner(Action action, int delayFrames)
{
mAction = action;
mDelayFrames = delayFrames;
}
internal void Run()
{
if (IsUnitTesting)
{
mAction();
return;
}
if (mIsOnDelay)
{
RefreshDelay();
return;
}
StartDelay();
}
void RefreshDelay()
{
mFramesOnDelay = mDelayFrames;
}
void StartDelay()
{
mIsOnDelay = true;
EditorApplication.update += OnUpdate;
RefreshDelay();
}
void EndDelay()
{
mIsOnDelay = false;
EditorApplication.update -= OnUpdate;
mAction();
}
void OnUpdate()
{
mFramesOnDelay--;
if (mFramesOnDelay <= 0)
EndDelay();
}
bool mIsOnDelay;
int mFramesOnDelay;
readonly int mDelayFrames;
readonly Action mAction;
}
}