Skip to content

Instantly share code, notes, and snippets.

Avatar
🏴‍☠️

Andrew Raphael Lukasik andrew-raphael-lukasik

🏴‍☠️
View GitHub Profile
@andrew-raphael-lukasik
andrew-raphael-lukasik / VeryUnsafeList.cs
Last active Jun 7, 2021
Unsafe list-like container built on generic pointers T* that can reallocate mid job execution using Allocator.Persistent
View VeryUnsafeList.cs
// 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;
public readonly Allocator allocator;
@andrew-raphael-lukasik
andrew-raphael-lukasik / Unity3DPaint.cs
Last active Mar 5, 2021
world point to texture coordinate + no mesh + arbitrary rotation
View Unity3DPaint.cs
// void* src: https://gist.github.com/andrew-raphael-lukasik/3a57c586017a593b6f8ba2a5b22133ff
using UnityEngine;
using UnityEngine.InputSystem;
public class Unity3DPaint : MonoBehaviour
{
[SerializeField][Min(4)] int _textureWidth = 64;
[SerializeField][Min(4)] int _textureHeight = 64;
[SerializeField] Vector2 _regionWorldSize = new Vector2{ x=100 , y=100 };
Texture2D _texture;
View TextureColorFillCalculator.cs
// void* src: https://gist.github.com/andrew-raphael-lukasik/73720c7a9aae0ff9faefd4f7b2a21660
using UnityEngine;
using UnityEngine.UIElements;
using UnityEditor;
using UnityEditor.UIElements;
public class TextureColorFillCalculator : EditorWindow
{
Texture2D _texture;
@andrew-raphael-lukasik
andrew-raphael-lukasik / GenerateRandomPointCloudMesh.cs
Last active Mar 2, 2021
point cloud mesh to billboards shader example
View GenerateRandomPointCloudMesh.cs
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 / Persistence.cs
Last active Apr 13, 2021
Skeleton structure for a save system.
View Persistence.cs
// 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 / SelectionSystem.cs
Last active Dec 7, 2020
Simple entity selection system
View SelectionSystem.cs
// 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 / NoiseFieldAuthoring.cs
Last active Jan 4, 2021
Generates noise field meshes with no seems between them (useful for generating terrain meshes).
View NoiseFieldAuthoring.cs
// src: https://gist.github.com/andrew-raphael-lukasik/104e5826015c2f4d47021ba564e9bfe8
// REQUIRES: com.unity.rendering.hybrid package
using System.Runtime.CompilerServices;
using System.Collections.Generic;
using UnityEngine;
using Unity.Mathematics;
using Unity.Entities;
using Unity.Rendering;
using Unity.Collections;
using Unity.Transforms;
@andrew-raphael-lukasik
andrew-raphael-lukasik / NoiseFieldMesh.cs
Last active Jan 4, 2021
MonoBehaviour * Unity.Jobs = simple and fast dynamic mesh generation method.
View NoiseFieldMesh.cs
// src: https://gist.github.com/andrew-raphael-lukasik/c83f1d9b3a356f36e0c66ddffbae3271
using System.Runtime.CompilerServices;
using UnityEngine;
using Unity.Mathematics;
using Unity.Collections;
using Unity.Jobs;
[RequireComponent( typeof(MeshFilter) , typeof(MeshRenderer) )]
public class NoiseFieldMesh : MonoBehaviour
{
@andrew-raphael-lukasik
andrew-raphael-lukasik / Worlds.cs
Last active Nov 22, 2020
(dots) code for world serialization and deserialization
View Worlds.cs
// 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
{
View SpatialHashAuthoringComponent.cs
// 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
{