Skip to content

Instantly share code, notes, and snippets.

View psuong's full-sized avatar

Porrith Suong psuong

View GitHub Profile
@jeffvella
jeffvella / TransformReader.cs
Created September 11, 2019 17:49
Reading GameObject Transform Component from pointer.
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Mathematics;
using UnityEngine;
public unsafe class TransformReader : MonoBehaviour
{
private NativeTransform* _transformPtr;
@jeffvella
jeffvella / PathTester.cs
Last active March 29, 2023 03:24
Find Path Tester for Unity Experimental Navigation
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Unity.Collections;
using Unity.Mathematics;
using UnityEditor;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Experimental.AI;
@timj-unity
timj-unity / system_update_order.md
Created March 21, 2018 00:19
Documentation for system update order

System update order

In ECS all systems are updated on the main thread. The order in which the are updated is based on a set of constraints and an optimization pass which tries to order the system in a way so that the time between scheduling a job and waiting for it is as long as possible. The attributes to specify update order of systems are [UpdateBefore(typeof(OtherSystem))] and [UpdateAfter(typeof(OtherSystem))]. In addition to update before or after other ECS systems it is possible to update before or after different phases of the Unity PlayerLoop by using typeof(UnityEngine.Experimental.PlayerLoop.FixedUpdate) or one of the other phases in the same namespace.

The UpdateInGroup attribute will put the system in a group and the same UpdateBefore and UpdateAfter attributes can be specified on a group or with a group as the target of the before/after dependency.

To use __UpdateIn

@nidev
nidev / .vimrc
Last active December 3, 2023 18:35
How to use omnisharp-vim with latest omnisharp-roslyn
"All user-dependent configurations are omitted intentionally.
"This gist only includes configurations for omnisharp.
"Original vimrc is available on:
"https://github.com/OmniSharp/omnisharp-vim#example-vimrc
"=========================================================
" **Preparation steps
"1. Install pathogen.vim or preferred plugin manager
"(Will explain procedures with assumption that a user is using pathogen.vim)
" **Main steps
@LotteMakesStuff
LotteMakesStuff / PlayerLoop.cs
Last active September 24, 2024 06: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;
@LotteMakesStuff
LotteMakesStuff / MinMaxAttribute.cs
Last active March 18, 2025 10:31
MinMax property drawer for Unity - Add a [MinMax] attribute to a property to draw a useful min/max setting slider.
// NOTE DONT put in an editor folder
using UnityEngine;
public class MinMaxAttribute : PropertyAttribute
{
public float MinLimit = 0;
public float MaxLimit = 1;
public bool ShowEditRange;
public bool ShowDebugValues;
inline bool intersect_ray_aabb(const glm::vec3 &origin, const glm::vec3 &dir, const AABB &aabb) {
float tmin, tmax, tymin, tymax, tzmin, tzmax;
glm::vec3 bounds[2];
bounds[0] = aabb.min();
bounds[1] = aabb.max();
glm::vec3 invdir = 1.f / dir;
glm::i8vec3 sign;
@formix
formix / xd2md.cs
Last active August 7, 2024 08:02
Generates Markdown From VisualStudio XML documentation files
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
namespace Formix.Utils
{
class Program
@richardkundl
richardkundl / BloomFilter.cs
Created January 7, 2014 14:29
Bloom filter implementation in c#.
namespace BloomFilter
{
using System;
using System.Collections;
/// <summary>
/// Bloom filter.
/// </summary>
/// <typeparam name="T">Item type </typeparam>
public class Filter<T>
@Shaptic
Shaptic / Triangulate.cpp
Last active July 11, 2021 19:32
Fokin' triangulation in C++.
#include <cstdint>
#include <list>
#include <vector>
#include <algorithm>
// This code uses C++11 features like "auto" and initializer lists.
// Compare two floating point numbers accurately.
bool compf(float a, float b, float threshold=0.00001f)
{