This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor.Build; | |
using UnityEditor.Build.Reporting; | |
using UnityEngine; | |
public class PreprocessBuild : IPreprocessBuildWithReport | |
{ | |
public int callbackOrder { get; } | |
public void OnPreprocessBuild(BuildReport report) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using UnityEngine; | |
/// <summary> | |
/// Delays execution of an action until a specified time has passed without it being triggered again. | |
/// Useful to prevent rapid-fire calls to expensive operations. | |
/// https://developer.mozilla.org/en-US/docs/Glossary/Debounce | |
/// </summary> | |
public class Debouncer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text.RegularExpressions; | |
using UnityEngine.Networking; | |
... | |
static Dictionary<string, string> ParseUrlQuery(string url) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Read lines from stdin into array: | |
lines=() | |
while IFS= read -r line; do | |
lines+=("$line") | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public partial class Flock : MonoBehaviour | |
{ | |
[SerializeField, Min(0)] float spawnRadius = 5f; | |
[SerializeField, Min(1)] int unitCount = 50; | |
[SerializeField] Transform unitPrefab; | |
[Header("Unit")] | |
[SerializeField, Range(0, 360)] float fieldOfView = 270f; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local eventManager <const> = {} | |
function addEventListener(eventName, listener) | |
local eventListeners = eventManager[eventName] | |
if not eventListeners then | |
eventListeners = {} | |
eventManager[eventName] = eventListeners | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Diagnostics; | |
using Unity.Collections; | |
using UnityEditor.Media; | |
using UnityEditor.Recorder.Encoder; | |
class HVECEncoder : IEncoder | |
{ | |
Process process; | |
public void OpenStream(IEncoderSettings settings, RecordingContext ctx) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
/// <summary> | |
/// Represents a color with hue, saturation, and lightness. | |
/// </summary> | |
readonly struct HSL | |
{ | |
public Color Color => HSV.FromHSL(this).Color; | |
public readonly float H; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adapted from https://stackoverflow.com/a/299526 | |
static IEnumerable<MethodInfo> GetExtensionMethods(Assembly assembly, Type extendedType) | |
{ | |
return assembly | |
.GetTypes() | |
.Where(type => type.IsSealed && !type.IsGenericType && !type.IsNested) | |
.SelectMany(type => type.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static)) | |
.Where(method => method.IsDefined(typeof(ExtensionAttribute), false) && | |
method.GetParameters()[0].ParameterType == extendedType); | |
} |
NewerOlder