Skip to content

Instantly share code, notes, and snippets.

View hk1ll3r's full-sized avatar
👨‍💻
Happily Coding

Hoss hk1ll3r

👨‍💻
Happily Coding
  • No Such Studio
  • Planet Earth
View GitHub Profile
public static class GenericToStringExts {
public static string ToStringExt<T>(this List<T> list) => "[" + string.Join(", ", list) + "]";
public static string ToStringExt<T>(this List<List<T>> listOfLists) => "[" + string.Join(", ", listOfLists.Select(l => l.ToStringExt())) + "]";
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public static class GenericToStringExts {
public static string ToStringExt<T>(this List<T> list) => "[" + string.Join(", ", list) + "]";
}
public static class MonoBehaviourExt
{
public static IEnumerator DelayedCoroutine(this MonoBehaviour mb, float delay, System.Action a)
{
yield return new WaitForSeconds(delay);
a();
}
public static Coroutine RunDelayed(this MonoBehaviour mb, float delay, System.Action a)
{
public class MyMonoBehaviour : MonoBehaviour {
protected IEnumerator DelayedCoroutine(float delay, System.Action a)
{
yield return new WaitForSecondsRealtime(delay);
a();
}
protected Coroutine RunDelayed(float delay, System.Action a)
{
return StartCoroutine(DelayedCoroutine(delay, a));
public class Buff : MonoBehaviour
{
public void OnBuff()
{
Debug.Log("buffed!");
RunDelayed(2f, () => {
Debug.Log("debuffed!");
});
}
@hk1ll3r
hk1ll3r / 20200205-rundelayed-usage.cs
Last active February 5, 2020 23:11
20200205-rundelayed-usage
public void OnBuff()
{
Debug.Log("buffed!");
RunDelayed(2f, () => {
Debug.Log("debuffed!");
});
}
{
"FormattingOptions": {
"NewLinesForBracesInLambdaExpressionBody": false,
"NewLinesForBracesInAnonymousMethods": false,
"NewLinesForBracesInAnonymousTypes": false,
"NewLinesForBracesInControlBlocks": false,
"NewLinesForBracesInTypes": false,
"NewLinesForBracesInMethods": false,
"NewLinesForBracesInProperties": false,
"NewLinesForBracesInObjectCollectionArrayInitializers": false,
void Awake() {
if (!Debug.isDebugBuild) {
Debug.Log("prod build");
enabled = false;
}
}
@hk1ll3r
hk1ll3r / 20200127-curlybraces-1.cs
Created January 27, 2020 23:36
sample bad format
void Awake()
{
if (!Debug.isDebugBuild)
{
Debug.Log("prod build");
enabled = false;
}
}
// mix and match
float y;
(float x, y) = GetPosition();
// throw away some returned values
(float x, _) = GetPosition();