Skip to content

Instantly share code, notes, and snippets.

View ashblue's full-sized avatar

Ash Blue ashblue

View GitHub Profile
@ashblue
ashblue / AutoParent.py
Created December 24, 2023 04:18
Automatically parent bones in Blender 3D to objects matching the pattern. Useful for rigging robots and mechanical skeletons.
import bpy
def parent_object_to_bone_by_name(armature, obj):
# Remove the 'O' prefix from the object's name to find the corresponding bone
bone_name = obj.name[1:] if obj.name.startswith("O") else None
if bone_name and bone_name in armature.pose.bones:
target_bone = armature.pose.bones[bone_name]
# Store the original world matrix of the object
@ashblue
ashblue / TriggerEvents.cs
Created October 15, 2019 01:39
A modular wrapper for Unity Triggers that makes them trigger events for enter and exit.
using Adnc.Utility;
using UnityEngine;
using UnityEngine.Events;
namespace CleverCrow.DungeonsAndHumans.Explorations {
public class TriggerEvents : MonoBehaviour {
private TriggerEventsInternal _internal;
[SerializeField]
private string _tag;
class Door : MonoBehavior {
private Fsm _fsmDoor;
private enum State {
Opened,
Closed,
Locked,
Unlocked,
ToggleLock,
}
@ashblue
ashblue / docker-compose.mongo.yml
Created January 6, 2018 23:31
Docker Compose example for MongoDB databases. Includes named volume support.
version: '3'
services:
mongodb:
image: mongo:3.6.1
container_name: uv-mongodb
volumes:
- mongodb:/data/db
- mongodb_config:/data/configdb
ports:
- 27017:27017
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Adnc.QuickParallax {
[CreateAssetMenu(fileName = "ParallaxSettings", menuName = "ADNC/Parallax/Settings", order = 1)]
public class ParallaxSettings : ScriptableObject {
private static ParallaxSettings _current;
private const string RESOURCE_PATH = "ParallaxSettings";
@ashblue
ashblue / SortableListBase.cs
Created August 3, 2017 15:52
A base class for managing sortable lists
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
namespace Adnc.Utility.Editors {
public abstract class SortableListBase {
protected ReorderableList _list;
protected Editor _editor;
protected SerializedObject _serializedObject;
@ashblue
ashblue / EditorPrefsObjectHelper.cs
Created July 31, 2017 15:16
Save and restore objects to the editor prefs
using UnityEditor;
using UnityEngine;
namespace Adnc.EditorHelpers {
public static class EditorPrefsObjectHelper {
/// <summary>
/// Save the object to the editor prefs. Only persists for the current editor session
/// </summary>
/// <param name="key"></param>
/// <param name="obj"></param>
@ashblue
ashblue / SortableList.cs
Created May 23, 2017 12:19
Create a sortable list with this re-usable class on the fly.
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
namespace Adnc.Pathfinding2D.Utility {
/// <summary>
/// Usage example:
/// [CustomEditor(typeof(MyBaseClass))]
@ashblue
ashblue / CountWords.gs
Created April 8, 2017 23:51
Google script for counting words in cell ranges.
function onOpen() {
var menu = [{name: 'Count Words', functionName: 'countWords'}];
SpreadsheetApp.getActive().addMenu('Count', menu);
}
function countWords() {
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getActiveRange().getValues();
var s = "";
@ashblue
ashblue / RestoreScriptableObject.cs
Last active January 13, 2016 14:53
Save and restore a scriptable object reference after your custom editor windows have been re-compiled.
using UnityEngine;
using UnityEditor;
public static class Wm {
const string DATABASE_ID_KEY = "MyCustomDatabase";
public static MyScriptableObject _db;
public static MyScriptableObject Db {
get {
if (_db == null && EditorPrefs.HasKey(DATABASE_ID_KEY)) {
_db = GetDatabaseFromStorage();