Skip to content

Instantly share code, notes, and snippets.

View WikkidEdd's full-sized avatar

Edd Smith WikkidEdd

View GitHub Profile
@jandk
jandk / jpeg.cs
Created October 14, 2012 21:09
(Almost) JPEG Decoder in C#
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
namespace Jpeg
{
@cosmogonies
cosmogonies / PrefabApplyCallback.cs
Last active March 8, 2022 14:36
Callback on Apply Prefab (Unity)
using UnityEngine;
using UnityEditor;
[InitializeOnLoad]
internal class PrefabExtension
{
static PrefabExtension()
{
UnityEditor.PrefabUtility.prefabInstanceUpdated += OnPrefabInstanceUpdate;
}
@FFouetil
FFouetil / EnumFlagAttribute.cs
Last active February 10, 2021 02:16 — forked from ChemiKhazi/EnumFlagAttribute.cs
Unity3d property drawer for automatically making enums flags into mask fields in the inspector.
using UnityEngine;
public class EnumFlagAttribute : PropertyAttribute
{
public string enumName;
public EnumFlagAttribute() {}
public EnumFlagAttribute(string name)
{
@yasirkula
yasirkula / CircleGraphic.cs
Last active October 24, 2024 06:10
Create circles/ellipses in Unity UI system in one of three modes: FillInside, FillOutside and Edge.
using UnityEngine;
using UnityEngine.UI;
#if UNITY_EDITOR
using UnityEditor;
// Custom Editor to order the variables in the Inspector similar to Image component
[CustomEditor( typeof( CircleGraphic ) ), CanEditMultipleObjects]
public class CircleGraphicEditor : Editor
{
@hyakugei
hyakugei / example.cs
Last active April 28, 2018 18:38
Unity3d IEnumerator, Coroutines and Partial Function Application
// Learning from https://codeblog.jonskeet.uk/2012/01/30/currying-vs-partial-function-application/
public void DoThings()
{
Func<Vector3, PlayerController, IEnumerator> orig = MoveToLocationAction;
var t = ApplyPartial(orig, data.eventObjects[0].point);
var t1 = ApplyPartial(t, player);
var tt = ApplyPartial(orig, data.eventObjects[1].point);
var tt1 = ApplyPartial(t, player);
@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;
}
@karljj1
karljj1 / Unity Assembly Definition Debugger.cs
Last active March 27, 2024 17:18
Find out what assemblies are being built and how long each takes.
using System;
using System.Collections.Generic;
using System.Text;
using UnityEditor;
using UnityEditor.Compilation;
using UnityEngine;
[InitializeOnLoad]
public class AsmdefDebug
{
@javier-games
javier-games / iOSHomeButton.cs
Last active September 29, 2024 01:53
Helps to modify the iOS home button parameters for each new scene or canvas on awake, you may consider add just one instance per scene.
using UnityEngine;
#if UNITY_IOS
using System.Collections.Generic;
using UnityEngine.UI;
#endif
/// <summary>
/// iOS Home Button.
///
@mootari
mootari / content-snippet.js
Last active March 17, 2024 14:14
Content Snippet that bundles the current page's stylesheets and assets into a zip file.
(async()=>{
const customCss = `
#title-heading {clear:left}
`;
const asyncArray = (iter, map) => Promise.all(Array.from(iter, map));
const css = (await asyncArray(
document.querySelectorAll('link[rel="stylesheet"][href^="/"]'),
async n => (await fetch(n.href, {mode: 'no-cors'})).text()
)).join("\n").replace(/\/\*.*?\*\//gs, '');
@totallyRonja
totallyRonja / MaterialGradientDrawer.cs
Last active November 13, 2024 11:51
A Material Property Drawer for the [Gradient] attribute which lets you edit gradients and adds them to the shader as textures. More information here: https://twitter.com/totallyRonja/status/1368704187580682240
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
public class MaterialGradientDrawer : MaterialPropertyDrawer {
private int resolution;