Skip to content

Instantly share code, notes, and snippets.

View WikkidEdd's full-sized avatar

Edd Smith WikkidEdd

View GitHub Profile
@aras-p
aras-p / ExportDDS.cs
Last active June 6, 2024 02:21
Unity DDS file exporter for compressed textures
// Adds context menu to TextureImporter objects, saves .dds next to input texture, including mipmaps.
// Tested with Unity 2021.3.4
using System;
using UnityEngine;
using UnityEditor;
using System.IO;
using Unity.Collections.LowLevel.Unsafe;
struct DDSHeader
@totallyRonja
totallyRonja / MaterialGradientDrawer.cs
Last active September 2, 2024 09:06
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;
@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, '');
@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.
///
@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
{
@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;
}
@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);
@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
{
@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)
{
@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;
}