Skip to content

Instantly share code, notes, and snippets.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Follow : MonoBehaviour {
[SerializeField]
private Transform follow = null;
private Vector3 originalLocalPosition;
@Rokobokode
Rokobokode / TweenExtensions.cs
Created February 11, 2020 20:37
Unity3D: DOTween: Tween As Task
public static class TweenExtensions
{
public static Task AsTask(this Tween tween, CancellationToken cancellationToken)
{
var taskCompletionSource = new TaskCompletionSource<bool>();
tween.OnComplete(() => { taskCompletionSource.TrySetResult(true); });
tween.OnKill(() => { taskCompletionSource.TrySetCanceled(); });
if (cancellationToken != CancellationToken.None)
@krzys-h
krzys-h / UnityWebRequestAwaiter.cs
Created July 20, 2018 22:47
[Unity] Use UnityWebRequest with async/await
public class UnityWebRequestAwaiter : INotifyCompletion
{
private UnityWebRequestAsyncOperation asyncOp;
private Action continuation;
public UnityWebRequestAwaiter(UnityWebRequestAsyncOperation asyncOp)
{
this.asyncOp = asyncOp;
asyncOp.completed += OnRequestCompleted;
}