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 / SpatialHashAuthoringComponent.cs
Last active August 9, 2023 21:07
unity dots spatial hashing (this was made for entities 0.17... I think)
// src: https://gist.github.com/andrew-raphael-lukasik/c8836b2b1f05e773abf9fb76dc7884af
using Unity.Entities;
using Unity.Mathematics;
using Unity.Collections;
using Unity.Transforms;
using Unity.Rendering;
using Unity.Jobs;
public class SpatialHashAuthoringComponent : UnityEngine.MonoBehaviour, IConvertGameObjectToEntity
{
@andrew-raphael-lukasik
andrew-raphael-lukasik / Worlds.cs
Last active November 12, 2022 20:53
(dots) code for world serialization and deserialization
// src: https://gist.github.com/andrew-raphael-lukasik/66d898be737734f26e607e6526d22901
using IO = System.IO;
using UnityEngine;
using Unity.Entities;
using Unity.Scenes;
using Unity.Entities.Serialization;
public static class Worlds
{
@andrew-raphael-lukasik
andrew-raphael-lukasik / .NoiseFieldMesh.cs.md
Last active September 28, 2023 18:53
MonoBehaviour * Unity.Jobs = simple and fast dynamic mesh generation method.

preview

@andrew-raphael-lukasik
andrew-raphael-lukasik / .NoiseFieldAuthoring.cs.md
Last active September 28, 2023 18:53
Generates noise field meshes with no seems between them (useful for generating terrain meshes).

preview

@andrew-raphael-lukasik
andrew-raphael-lukasik / SelectionSystem.cs
Last active August 9, 2023 20:46
Simple entity selection system
// src: https://gist.github.com/andrew-raphael-lukasik/917046557baed6646c9fdc3b40671307
using UnityEngine;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Collections;
using Unity.Rendering;
[UpdateInGroup( typeof(PresentationSystemGroup) )]
public class SelectionSystem : SystemBase
{
@andrew-raphael-lukasik
andrew-raphael-lukasik / Persistence.cs
Last active July 10, 2023 08:38
Skeleton structure for a save system.
// src: https://gist.github.com/andrew-raphael-lukasik/e02f21cc507da9e5eb7569b8793e70f4
using System.Collections.Generic;
using System.Linq;
using IO = System.IO;
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.UIElements;
#if UNITY_EDITOR
using UnityEditor.UIElements;
#endif
@andrew-raphael-lukasik
andrew-raphael-lukasik / GenerateRandomPointCloudMesh.cs
Last active December 11, 2023 05:12
point cloud mesh to billboards shader example
using UnityEngine;
using Random = Unity.Mathematics.Random;
[RequireComponent( typeof(MeshFilter) , typeof(MeshRenderer) )]
public class GenerateRandomPointCloudMesh : MonoBehaviour
{
Mesh _mesh;
[SerializeField] int _numVerties = 100;
void Awake ()
{
_mesh = new Mesh();
@andrew-raphael-lukasik
andrew-raphael-lukasik / .TextureColorFillCalculator.cs.md
Last active September 28, 2023 18:52
Texture Color Fill Calculator

test1 test2 test3 test4

@andrew-raphael-lukasik
andrew-raphael-lukasik / .Unity3DPaint.cs.md
Last active September 28, 2023 18:52
world point to texture coordinate + no mesh + arbitrary rotation

preview

@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;