Skip to content

Instantly share code, notes, and snippets.

View friuns2's full-sized avatar

Brutal Strike friuns2

View GitHub Profile
@AngryAnt
AngryAnt / Build.sh
Created September 30, 2012 07:21
Example code for "Downloading the hydra" blog post on AngryAnt.com
mcs -target:library -out:MyAssembly.dll -r:/Applications/Unity/Unity.app/Contents/Frameworks/UnityEngine.dll MyAssembly.cs
@psayre23
psayre23 / gist:c30a821239f4818b0709
Last active June 27, 2024 17:48
Runtime Complexity of Java Collections
Below are the Big O performance of common functions of different Java Collections.
List | Add | Remove | Get | Contains | Next | Data Structure
---------------------|------|--------|------|----------|------|---------------
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array
@jbevain
jbevain / README.md
Last active November 16, 2023 12:11
pdb2mdb for Visual Studio 2015

The Visual Studio Tools for Unity are able to convert .NET debug symbol files (namely pdb files) to debug symbols files that are understood by Unity's scripting engine (namely .dll.mdb files) when importing both the .dll and the .pdb in the Assets folder.

If you prefer to handle the conversion yourself you need to call a tool named pdb2mdb on the .dll associated with the .pdb:

pdb2mdb MyLibrary.dll

Will produce a MyLibrary.dll.mdb usable on Unity if MyLibrary.pdb is present.

@LotteMakesStuff
LotteMakesStuff / PlayerLoop.cs
Last active March 25, 2024 02:38
Player Loop Visualizer: Built to explore the new PlayerLoopSystem api in Unity 2018.1b2. This tool shows you all the PlayerLoop systems that unity uses to update a frame, and demos how to add your own and even remove systems from the player loop. For more info see the patreon post https://www.patreon.com/posts/unity-2018-1-16336053
// Put this in an editor folder
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.Experimental.LowLevel;
using UnityEngine.Profiling;
@lacostej
lacostej / UnityProgress_2017.1.js
Created January 15, 2018 15:32
Unity WebGL progress bar template for Unity 2017.1
// https://docs.unity3d.com/2017.1/Documentation/Manual/webgl-templates.html example code is broken. Use:
function UnityProgress(gameInstance, progress) {
if (!gameInstance.Module)
return;
var r = UnityLoader.Progress.Styles[gameInstance.Module.splashScreenStyle],
n = gameInstance.Module.progressLogoUrl ? gameInstance.Module.resolveBuildUrl(gameInstance.Module.progressLogoUrl) : r.progressLogoUrl,
o = gameInstance.Module.progressEmptyUrl ? gameInstance.Module.resolveBuildUrl(gameInstance.Module.progressEmptyUrl) : r.progressEmptyUrl,
i = gameInstance.Module.progressFullUrl ? gameInstance.Module.resolveBuildUrl(gameInstance.Module.progressFullUrl) : r.progressFullUrl,
a = "position: absolute; left: 50%; top: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);";
if (!gameInstance.logo) {
@PopupAsylumUK
PopupAsylumUK / HexGridLayout.cs
Last active May 3, 2024 02:04
A Layout group for arranging children in a hexagon grid, and a Hexagon graphic
using UnityEngine;
using UnityEngine.UI;
public class HexGridLayout : LayoutGroup {
const float SQUARE_ROOT_OF_3 = 1.73205f;
public enum Axis { Horizontal = 0, Vertical = 1 }
public enum Constraint { Flexible = 0, FixedColumnCount = 1, FixedRowCount = 2 }
@WikkidEdd
WikkidEdd / FindSceneRefs.cs
Last active November 19, 2023 11:53
Find references within a scene on a right click context menu for components. As per this tweet https://twitter.com/KarlJamesJones/status/1026756113218371586 Note: Only tested with 2017.4.6
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Reflection;
using System;
public class FindSceneRefs {
[MenuItem("CONTEXT/Component/Find References In Scene")]
@yasirkula
yasirkula / TMP_IntegerText.cs
Last active May 12, 2024 22:04
Show numbers (int, float etc.) on TextMesh Pro texts without any GC allocations
//#define TMP_ROUND_DECIMALS // When defined, float and double values are rounded using Math.round
using TMPro;
public static class TMP_IntegerText
{
private static readonly char[] arr = new char[64]; // prefix + number + postfix can't exceed this capacity!
private static int charIndex = 0;
public static void SetText( this TMP_Text text, sbyte number )
@sinbad
sinbad / SpriteMeshRaycastFilter.cs
Last active May 11, 2023 05:35
SpriteMeshRaycastFilter: easy Unity UI non-rectangular click detector without reading textures
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
// Restrict raycasting to a sprite mesh shape
// Could use Image.alphaHitTestMinimumThreshold to mask but that requires read/write images which can't be packed
[RequireComponent(typeof(Image))]
public class SpriteMeshRaycastFilter : MonoBehaviour, ICanvasRaycastFilter {
private RectTransform rectTransform;
@emadkhezri
emadkhezri / ToggleFieldAttribute.cs
Created September 7, 2021 12:24
Attribute that makes a field enable/disable status controlled by a boolean condition
/// <summary>
/// Attribute that makes a field enable/disable status controlled by a boolean condition
/// </summary>
public class ToggleFieldAttribute : PropertyAttribute {
/// <summary>
/// Boolean field to control the enable/disable status
/// </summary>
public readonly string ConditionalField;