Skip to content

Instantly share code, notes, and snippets.

View thebeardphantom's full-sized avatar

Mika Notarnicola thebeardphantom

View GitHub Profile
@thebeardphantom
thebeardphantom / FastNoiseRNG.cs
Created December 16, 2020 10:27
A mechanism to use FastNoiseLite as a proper RNG class.
using System.Collections.Generic;
using UnityEngine;
public class FastNoiseRNG : FastNoiseLite
{
#region Fields
private ulong _position;
#endregion
@thebeardphantom
thebeardphantom / SerializedPropertyUtility.cs
Created March 4, 2021 23:34
Find FieldInfo for a given SerializedProperty.
public static class SerializedPropertyUtility
{
private static readonly MethodInfo getFieldInfoFromProperty;
static SerializedPropertyUtility()
{
var scriptAttributeUtility = typeof(UnityEditor.Editor).Assembly.GetType("UnityEditor.ScriptAttributeUtility");
Assert.IsNotNull(scriptAttributeUtility, "ScriptAttributeUtility != null");
getFieldInfoFromProperty = scriptAttributeUtility.GetMethod(nameof(GetFieldInfoFromProperty), BindingFlags.NonPublic | BindingFlags.Static);
using Cysharp.Threading.Tasks;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using UnityEditor;
using UnityEditor.Recorder;
using UnityEditor.Recorder.Input;
using UnityEngine;
[DefaultExecutionOrder(-50)]
public class IconRecorder : MonoBehaviour
@thebeardphantom
thebeardphantom / TaskData.cs
Last active February 16, 2022 10:32
Simple, efficient task scheduler for Unity using SortedSet<T>.
using UnityEngine;
public readonly struct TaskData
{
#region Fields
public readonly double ExecTime;
public readonly double DelayTime;
using System;
using System.Linq;
using UnityEditor;
using UnityEditor.ShortcutManagement;
using UnityEngine;
[InitializeOnLoad]
public class PlayModeShortcutManagerProfileUtility
{
#region Types
@thebeardphantom
thebeardphantom / AttenuationCurve.cs
Last active June 17, 2022 23:42
AttenuationCurve
using System;
using Unity.Mathematics;
using UnityEngine;
[Serializable]
public struct AttenuationCurve
{
#region Properties
[field: SerializeField]
@thebeardphantom
thebeardphantom / BlenderSupportFunctions.cs
Last active September 4, 2023 16:49
Improvements to Unity <-> Blender <-> FBX <-> Blendfile workflows. See readme.txt.
using System;
using System.Diagnostics;
using System.IO;
using Unity.Logging;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEngine;
using Debug = UnityEngine.Debug;
public class BlenderSupportFunctions : AssetPostprocessor
@thebeardphantom
thebeardphantom / GSheetImporter.cs
Last active October 29, 2023 10:35
Simple .gsheet to TextAsset ScriptedImporter for Unity, with code from https://gist.github.com/jasonleehodges/359eb2af0d1caec0153bb7450c165ffd
[ScriptedImporter(1, "gsheet")]
public class GSheetImporter : ScriptedImporter
{
#region Types
private class WebClientEx : WebClient
{
#region Fields
private readonly CookieContainer _container;
@thebeardphantom
thebeardphantom / CsvDataGenerator.CsvFile.cs
Last active January 27, 2024 11:06
An example of generating ScriptableObjects and populating their serialized properties via CSV files.
using System;
using System.Linq;
using UnityEngine;
public static partial class CsvDataGenerator
{
#region Types
public class CsvFile
{
@thebeardphantom
thebeardphantom / PoissonJob.cs
Created January 29, 2024 09:03
A port of Fast Poisson Disk Sampling for Unity to the Jobs System (https://gist.github.com/a3geek/8532817159b77c727040cf67c92af322)
using System;
using Unity.Burst;
using Unity.Collections;
using Unity.Jobs;
using Unity.Mathematics;
using UnityEngine;
using Random = Unity.Mathematics.Random;
/*
* A port of Fast Poisson Disk Sampling for Unity to the Jobs System.