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 / Binary Reader & Writer.cs
Last active December 27, 2022 03:51
Unity.Entities.Serialization.BinaryReader basic implementation
// src: https://gist.github.com/andrew-raphael-lukasik/6813fe2b8688eb3ea4e333f21d3cc02a
namespace Unity.Entities.Serialization
{
public unsafe struct Reader : BinaryReader
{
System.IO.BinaryReader _reader;
System.IO.FileStream _stream;
public Reader ( string filePath )
{
@andrew-raphael-lukasik
andrew-raphael-lukasik / .CapsuleCapsuleIntersection.cs.md
Last active September 28, 2023 18:51
capsule-capsule intersection test (also segment-segment)

capsule-capsule intersection test

@andrew-raphael-lukasik
andrew-raphael-lukasik / .ButtonThatCanBeDisabled.cs.md
Last active September 28, 2023 18:51
UI Toolkit Button class that can be disabled via style sheet or uxml inline property

Button class that can be disabled via style sheet or uxml inline property

how to disable a Button from UI Builder

@andrew-raphael-lukasik
andrew-raphael-lukasik / .GpuInstancingForGameObjects.cs.md
Last active April 15, 2024 15:32
GPU Instancing for GameObjects

GPU Instancing for GameObjects

frustum culling, multiple materials are being segregated into batches with their own AABB:

@andrew-raphael-lukasik
andrew-raphael-lukasik / .VoronoiTextureBurstJobComponent.md
Last active November 9, 2023 22:11
How to create a Voronoi diagram texture, IJobParallelFor + Burst
  • euclidean (left), manhattan (right)

@andrew-raphael-lukasik
andrew-raphael-lukasik / .LetFindNearestTargets.cs.md
Last active April 23, 2024 21:39
| How to use TransformAccessArray | How to add Transform to TransformAccessArray mid execution | How to remove Transform from TransformAccessArray mid execution |

24gevbpq93uREUwegh9u32ibqae9uyshdfbwep23ugo99832ewuTW$Ewwt

@andrew-raphael-lukasik
andrew-raphael-lukasik / ConvertGameObjectHierarchyExample.cs
Last active April 19, 2022 16:41
GameObject-Entity conversion examples
using UnityEngine;
using Unity.Entities;
public class ConvertGameObjectHierarchyExample : MonoBehaviour
{
[SerializeField] GameObject _prefab = null;
BlobAssetStore _blobAssetStore;
void Awake ()
{
var world = World.DefaultGameObjectInjectionWorld;
@andrew-raphael-lukasik
andrew-raphael-lukasik / Mem.cs
Last active November 29, 2022 23:24
MemCpy between unmanaged and managed arrays
// src* https://gist.github.com/andrew-raphael-lukasik/b5cd9eb0c6f36388069d3211554409de
using UnityEngine;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
// Project Settings/Player/Other Settings/Script Compilation/Allow `Unsafe` Code = ☑
public static class Mem
{
public static unsafe bool Cpy<SRC, DST>(NativeArray<SRC> src, DST[] dst)
@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 / simd.cs
Last active December 13, 2022 11:10
my thoughts on simd and Burst
using Unity.Collections;
using Unity.Jobs;
using Unity.Mathematics;
using BurstCompile = Unity.Burst.BurstCompileAttribute;
[BurstCompile] public unsafe struct NoSimd : IJob
{
public float a, b;
public float* c;
void IJob.Execute () { *c = a * b; }