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 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)
{
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 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())) + "]";
}
class Program
{
static void Main(string[] args)
{
var strList = new List<string>() {"one", "two", "three"};
Console.WriteLine("ToString: " + strList.ToString());
}
}
class Program
{
static void Main(string[] args)
{
var listOfLists = new List<List<string>>() { new List<string>() {"one", "two"}, new List<string>() {"three", "four"}};
Console.WriteLine("ToString: " + listOfLists.ToString());
Console.WriteLine("ToStringExt: " + listOfLists.ToStringExt());
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace NoSuchStudio.Common
{
public static class GenericToStringExts
{
// Dictionary's KeyValuePair
class Program
{
static void Main(string[] args)
{
var strList = new List<string>() {
"one", "two", "three"
};
Console.WriteLine(strList.ToStringExt());
}
}
class Program
{
static void Main(string[] args)
{
var listOfLists = new List<List<string>>() {
new List<string>() {"one", "two"},
new List<string>() {"three", "four"}
};
Console.WriteLine(listOfLists.ToStringExt());
// output: [[one, two], [three, four]]
using System;
using System.Collections.Generic;
using UnityEngine;
namespace NoSuchStudio.Common {
/// <summary>
/// Base class for MonoBehaviours that should have a separate logger. Useful for filtering
/// logs by class types.
/// </summary>
using UnityEngine;
using NoSuchStudio.Common;
public class MyClassB : MonoBehaviour {
void Start() {
this.LogLog("Hello World!");
}
}