Skip to content

Instantly share code, notes, and snippets.

View andrew-raphael-lukasik's full-sized avatar
🏴‍☠️

Andrew Raphael Lukasik andrew-raphael-lukasik

🏴‍☠️
View GitHub Profile
@andrew-raphael-lukasik
andrew-raphael-lukasik / RequireReference.cs
Last active July 9, 2018 16:07
Mark your fields with [RequireReference] attribute to make them glow red if null
//SOURCE: https://gist.github.com/andrew-raphael-lukasik/60e6dc072dc170ab535a7aff961c3ba9
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
//TODO: Add build-time warnings
using System;
using System.IO;
namespace SevenZip.Compression.LZMA
{
public static class SevenZipHelper
{
static int dictionary = 1 << 23;
using UnityEngine;
using Unity.Collections;
using Unity.Mathematics;
public class DynamicMeshData : System.IDisposable
{
#region FIELDS & PROPERTIES
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CoroutineController : MonoBehaviour
{
static CoroutineController _singleton;
static Dictionary<string,IEnumerator> _routines = new Dictionary<string,IEnumerator>(100);
[RuntimeInitializeOnLoadMethod( RuntimeInitializeLoadType.BeforeSceneLoad )]
@andrew-raphael-lukasik
andrew-raphael-lukasik / MeshTrianglesToEdges.cs
Created September 19, 2020 21:44
creates array of edges from array of mesh triangles
int2[] ToEdges ( int[] triangles )
{
var edges = new Dictionary<ulong,int2>();
for( int i=0 ; i<triangles.Length ; i+=3 )
{
int a = triangles[i];
int b = triangles[i+1];
int c = triangles[i+2];
ulong hash;
@andrew-raphael-lukasik
andrew-raphael-lukasik / VeryUnsafeList.cs
Last active July 23, 2021 21:28
Unsafe list-like container built on generic pointers T* that can reallocate mid job execution using Allocator.Persistent
// src*: https://gist.github.com/andrew-raphael-lukasik/09c8a9c29bb5548ea65273653474f8f1
using UnityEngine;
using UnityEngine.Assertions;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
public unsafe struct VeryUnsafeList <T> : System.IDisposable where T : unmanaged
{
public T* ptr;
@andrew-raphael-lukasik
andrew-raphael-lukasik / Array2DView.cs
Last active October 10, 2021 08:39
tiny facade struct that provides [x,y] indexer accessors for arrays
// src* = https://gist.github.com/andrew-raphael-lukasik/b1cba7b10407c7540e33f1c0a9930746
using UnityEngine;
public struct Array2DView <T>
{
public T[] array;
public int width, height;
public T this [ int i ]
{
get
@andrew-raphael-lukasik
andrew-raphael-lukasik / LineSegmentDrawer.cs
Last active April 7, 2022 20:55 — forked from unitycoder/LineDrawer.cs
Custom geometry with UI Toolkit
// src* https://gist.github.com/andrew-raphael-lukasik/7229d38dbbc0baa3c2a2ab106fb4f7ef
using UnityEngine;
using UnityEngine.UIElements;
[UnityEngine.Scripting.Preserve]
public class LineSegmentDrawer : VisualElement
{
public float startX { get; set; }
public float startY { get; set; }
public float endX { get; set; }
@andrew-raphael-lukasik
andrew-raphael-lukasik / IncreaseBuildNumberAutomatically.cs
Last active April 9, 2022 07:34
Increase Build Number Automatically (Unity3d 2017.1.*)
//SOURCE: https://gist.github.com/andrew-raphael-lukasik/36a30f0955d7cdc758e394dc4e7266bf
using System.Collections;
using UnityEngine;
using UnityEditor;
using UnityEditor.Build;
public class IncreaseBuildNumberAutomatically : IPreprocessBuild
// src: https://gist.github.com/andrew-raphael-lukasik/709c19dd2305a2d1a0fa32ee82717b5c
using Unity.Collections;
public unsafe struct NativeStack <T> : System.IDisposable
where T : unmanaged
{
NativeList<T> _list;
public bool IsCreated => _list.IsCreated;
public int Length => _list.Length;