Skip to content

Instantly share code, notes, and snippets.

@kyuskoj
kyuskoj / Hair.cs
Created October 25, 2021 10:20
Hair simulation with Unity 2D Animation
using System;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.U2D;
namespace Son.Modules
{
public class Hair : MonoBehaviour
{
@kyuskoj
kyuskoj / UpdateInspector.cs
Last active September 25, 2021 13:34
Force the Inspector to update every 0.1 seconds. (Unity)
private IEnumerator UpdateInspector()
{
var inspectorWindowType = typeof(Editor).Assembly.GetType("UnityEditor.InspectorWindow");
var targetInspector = EditorWindow.GetWindow(inspectorWindowType, false, null, false);
while (targetInspector)
{
targetInspector.Repaint();
yield return YieldCache.WaitForSeconds(.2f);
}
}
@kyuskoj
kyuskoj / CreateDLL.cs
Last active September 25, 2021 13:31
Create dll for Unity.
public void CreateDLL(string name)
{
var assemblyName = new AssemblyName(AssemblyName);
var fileName = $"{AssemblyName}.{name}.dll";
AssemblyBuilder assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave, "Assets/Plugins/");
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name, fileName);
EnumBuilder enumData = moduleBuilder.DefineEnum($"{AssemblyName}.{name}", TypeAttributes.Public, typeof(int));
for (int i = 0; i < Container.TypeNames.Count; i++)
enumData.DefineLiteral(Container.TypeNames[i].Replace(" ", ""), i);
@kyuskoj
kyuskoj / Xoroshiro128Plus.cs
Last active September 25, 2021 13:31
simple Xoroshiro128Plus for Unity.
using System;
namespace Pulsar.Utils
{
public static class Xoroshiro128Plus
{
private const int A = 24, B = 16, C = 37;
// float has a maximum of '24' bits of precision. This means that not all integers larger than 16777216 can be represented exactly.
private const long FloatMask = (1L << 24) - 1;
private const float Normalize24 = 1.0f / (1L << 24);