Skip to content

Instantly share code, notes, and snippets.

View Bian-Sh's full-sized avatar

雨落随风 Bian-Sh

View GitHub Profile
@YN-Studio
YN-Studio / MeasureToolEditor.cs
Created October 14, 2023 03:10
基于Odin Inspector的Unity2D测量工具。Unity2D measure tool using Odin Inspector
using System.Collections.Generic;
using Sirenix.OdinInspector;
using Sirenix.OdinInspector.Editor;
using UnityEditor;
using UnityEngine;
/// <summary>
/// 地编中使用的测量工具(2D)
/// </summary>
public class MeasureToolEditor : OdinEditorWindow
@yasirkula
yasirkula / SlicedFilledImage.cs
Last active July 3, 2024 07:44
Combining UI Image's Sliced+Filled features together in Unity
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
#if UNITY_2017_4 || UNITY_2018_2_OR_NEWER
using UnityEngine.U2D;
#endif
using Sprites = UnityEngine.Sprites;
#if UNITY_EDITOR
@fishtopher
fishtopher / HighlightAttribute.cs
Last active November 28, 2023 04:23
Highlight Property Drawer - Simply sets the text/background colour of a field in the inspector.
// Do NOT put me in an /Editor/ folder
// Questions/bugs: chris@vitei.com
using UnityEngine;
public class HighlightAttribute : PropertyAttribute {
public Color col;
public HighlightAttribute(float r=1, float g=0, float b=0) {
this.col = new Color(r,g,b,1);
@LotteMakesStuff
LotteMakesStuff / EditorExtensionMethods.cs
Last active April 28, 2023 09:50
A reimplementation of the logic in the Unity Editor that draws an inspector for a component. We can use this to learn how unity actually draws the inspector. for more info see https://www.patreon.com/posts/16724128
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Reflection;
public static class EditorExtensionMethods
{
// Public reimplmentation of extention methods and helpers that are marked internal in UnityEditor.dll
@LotteMakesStuff
LotteMakesStuff / InspectorButtonsTest.cs
Last active November 2, 2023 21:03
Code running pack! two property drawing scripts that make it super easy to trigger code via buttons in the inspector, and get feedback! [TestButton] draws you little buttons that call a method on your MonoBehaviour, and [ProgressBar] give you a great way to show feedback from long running methods. These are *super* helpful for things like proced…
using UnityEngine;
using System.Collections;
public class InspectorButtonsTest : MonoBehaviour
{
[TestButton("Generate world", "DoProcGen", isActiveInEditor = false)]
[TestButton("Clear world", "ClearWorld", 2, isActiveInEditor = false)]
[ProgressBar(hideWhenZero = true, label = "procGenFeedback")]
public float procgenProgress = -1;
@sabresaurus
sabresaurus / AutoComponentAttribute.cs
Last active July 28, 2021 17:49
Automatic binding of component references
// MIT License
//
// Copyright (c) 2018 Sabresaurus
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@treefortress
treefortress / ParticleScaler.cs
Last active October 7, 2019 04:29
Scale Unity ParticleSystem at Runtime
using UnityEngine;
public static class ParticleExtensions
{
/// Add Extension to the native ParticleSystem class.
/// eg: myParticleSystem.Scale(2);
public static void Scale(this ParticleSystem particles, float scale, bool includeChildren = true) {
ParticleScaler.Scale(particles, scale, includeChildren);
}
@thelucre
thelucre / transparentbg-unity-webgl.jslib
Last active August 11, 2023 07:44
Transparent WebGL Rendering
// Source: http://forum.unity3d.com/threads/webgl-transparent-background.284699/#post-1880667
// Clears the WebGL context alpha so you can have a transparent Unity canvas above DOM content
// Add this .jslib to your project et voila!
var LibraryGLClear = {
glClear: function(mask)
{
if (mask == 0x00004000)
{
var v = GLctx.getParameter(GLctx.COLOR_WRITEMASK);
if (!v[0] && !v[1] && !v[2] && v[3])
@wzup
wzup / .bashrc
Last active May 17, 2023 00:49
alias for Git Bash on Windows
# create a file C:\Users\[user]\.bashrc
# add this content
# add your onw aliases or changes these ones as you like
# to make a dot (.bashrs) file in windows, create a file ".bashrs." (without extention) and save. windows will save it as ".bashrc"
alias ls='ls -alh'
alias cdnginx='cd /c/nginx && ls'
alias cdmcga='cd /c/Users/[user]/sbox/node/mcga && ls'
alias cdfood9='cd /c/Users/[user]/sbox/node/food9 && ls'
alias cdmysql='cd /c/nginx/mysql/bin && ls'
@liortal53
liortal53 / DecoratorEditor.cs
Last active May 10, 2024 14:28
Extend Unity's built-in inspectors
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
/// <summary>
/// A base class for creating editors that decorate Unity's built-in editor types.
/// </summary>
public abstract class DecoratorEditor : Editor