Skip to content

Instantly share code, notes, and snippets.

View koster's full-sized avatar

xk koster

View GitHub Profile
@koster
koster / fix_unity_build_permissions.sh
Created June 5, 2025 13:41
bash script to fix unity mac os builds not starting if they're unsigned
#!/bin/bash
# put this next to your game's *.app file and run
APP_PATH="$(dirname "$0")"/*.app
echo "Making all .app bundles in this folder executable..."
chmod -R +x $APP_PATH
echo "Removing quarantine attribute..."
@koster
koster / LogToFile.cs
Last active June 7, 2025 20:04
LogToFile in standalone builds for unity
using System;
using System.IO;
using UnityEngine;
public class LogToFile : MonoBehaviour
{
#if !UNITY_EDITOR && !UNITY_WEBGL
private string logFilePath;
private StreamWriter logWriter;
private int logCounter = 0;
@koster
koster / CMSEntityExplorer.cs
Created December 10, 2024 18:42
CMSEntityExplorer.cs
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using UnityEditor.IMGUI.Controls;
public class CMSEntityExplorer : EditorWindow
{
private const string SEARCH_PATH = "Assets/ldgame/data/Resources";
private string searchQuery = "";
@koster
koster / CompileTimeLogger.cs
Created December 7, 2024 19:30
Unity editor script that logs how long it takes for your project to compile and get into play mode
using System;
using UnityEditor;
using UnityEditor.Compilation;
[InitializeOnLoad]
public static class CompileTimeLogger
{
private const string CompileStartTimeKey = "CompileStartTime";
private const string PlayModeTimerKey = "PlayModeStartTime";
@koster
koster / ChatGPTVerletRope.cs
Last active February 25, 2025 18:57
ChatGPT verlet rope
using UnityEngine;
public class VerletRope : MonoBehaviour
{
public Transform startPoint; // Начальная точка верёвки
public Transform endPoint; // Конечная точка верёвки
public int segmentCount = 10; // Количество сегментов верёвки
public float segmentLength = 0.2f; // Длина каждого сегмента
public int simulationIterations = 5; // Количество итераций симуляции
public float gravity = -9.8f; // Гравитация
@koster
koster / ResourceClassGenerator.cs
Last active June 7, 2025 20:07
Generate a static class structure that mimics your /Resources folder
// say you have Resources/test1.prefab
// /folder
// sound.wav
// this will generate
// class GameResources
// GameObject test1
// class Folder
// AudioClip sound
// and you'll be able to do
// GameResources.Folder.sound in your code!
@koster
koster / TagDescription.cs
Last active October 29, 2024 21:55
A funky description system
// this handles strings like
// Ignores %TagDiceModifierIgnoresArmor::value% armor
// and stuff, useful for complex descriptions
[Serializable]
public class TagDescription : EntityComponentDefinition
{
public string loc;
public string ParseTagDescription(CMSEntity entity)
@koster
koster / autobuilder.py
Last active February 22, 2025 08:30
CI/CD for itch.io
# builds unity webgl build and uploads it to itch
# you'll need an itch.io butler for this
# https://itch.io/docs/butler/login.html
import os
import subprocess
import time
from git import Repo
# Configuration
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class RaycastInverter : Mask
{
public override bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera)
{
return !base.IsRaycastLocationValid(sp, eventCamera);
@koster
koster / LocSystem.cs
Last active May 21, 2025 21:21
A compact loc system that needs no setup
// Just create a bunch LocString's anywhere
// change Loc.language and you're done
using System.Collections.Generic;
using System;
using System.Collections.Generic;