Skip to content

Instantly share code, notes, and snippets.

View lordlycastle's full-sized avatar
🤙
Let it Fly!

lordlycastle

🤙
Let it Fly!
View GitHub Profile
@lordlycastle
lordlycastle / OdinFilePathTest.cs
Created July 1, 2019 11:02
Window keeps expanding width ways.
using System;
using Sirenix.OdinInspector;
using Sirenix.OdinInspector.Editor;
using Sirenix.Serialization;
using UnityEditor;
public class OdinFilePathTest : OdinEditorWindow
{
[HorizontalGroup("File", width:0.75f), PropertyOrder(0)]
[FilePath(RequireExistingPath = true)]
@lordlycastle
lordlycastle / BaseSingleton.cs
Last active March 10, 2025 14:32
Abstract singleton class for Unity.
using System.Linq;
using UnityEngine;
/// <summary>
/// Abstract singleton class for Unity. Updated with possible errors:
/// - Doesn't create a new singleton if it is in scene.
/// - Singleton has an initialize method which is called on creation, finding one from scene, or awake. Which makes sure initialization always happen before using it.
/// - It doesn't create a new single if you try to access it OnDestroy (e.g. game quit). Returns null instead.
/// </summary>
/// <typeparam name="TSingleton">Type of singleton. (Same as class inheriting from it.)</typeparam>
@lordlycastle
lordlycastle / DataSerializer.cs
Last active May 9, 2024 22:21
Inspector window that can serialize an object to disk and load it back up. Can use various methods e.g. binary, JSON, nodes. Good for saving data to disk for later use.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Sirenix.OdinInspector;
@lordlycastle
lordlycastle / StringEnumMap.cs
Created July 3, 2019 16:58
This class allows you to have enum like functionality but with their string values. It supports multiple string values and conversion to&from them. Kinda handy but no inspector :(
namespace Luminous.Tools
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
@lordlycastle
lordlycastle / StringEnumTests.cs
Created July 3, 2019 16:59
Tests for StringEnumMap class. It also shows how the class can be used.
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Luminous.Tools;
using NUnit.Framework;
namespace Luminous.Tests
{
public class StringEnumTests
@lordlycastle
lordlycastle / KeyValueContainer.cs
Last active November 4, 2022 00:47
A container class that wraps around `KeyValuePair` to make it "mutable". Also Unity inspector friendly.
/// <summary>
/// A container class which encapsulates the KeyValuePair so it shows up in the editor.
/// Also allows us to update key and value without much hassle.
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
[Serializable]
public class KeyValuePairContainer<TKey, TValue>
{
/// <summary>

下面是一堆awesome-*列表轮子,想看干货的童靴可以随意打开一个轮子:

  • Awesome - A curated list of awesome lists
  • awesome-all – A curated list of awesome lists of awesome frameworks, libraries and software
  • awesome-awesome by @emijrp – A curated list of awesome curated lists of many topics.
  • awesome-awesome by @erichs – A curated list of awesome curated lists! Inspired by inspiration.
  • awesome-awesome by @oyvindrobertsen – A curated list of curated lists of libraries, resources and shiny things for various languages.
  • awesome-awesomeness – A curated list of awesome awesomeness
  • awesome-awesomes – Awesome collection of awesome lists of libraries, tools, frameworks and software for any programming language
@lordlycastle
lordlycastle / JsonFormatter.cs
Created October 1, 2019 10:44
A basic script that allows you to format JSON string.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Luminous.Tools
{
/// <summary>
/// A utility to format JSON in pretty text.
/// </summary>
# Created by https://www.gitignore.io/api/unity,windows,visualstudio
# Build folder
__UWP/**
__UWP_Build/**
UWP/**
### Unity ###
[Ll]ibrary/
[Tt]emp/
//Shader imported from https://docs.chaosgroup.com/display/OSLShaders/Thin+Film+Shader
Shader "Custom/ThinFilmIridescence" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
[Normal]_Normal("Normal", 2D) = "bump" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_ThicknessMin("ThicknessMin", float) = 250
_ThicknessMax("ThicknessMax", float) = 400