Skip to content

Instantly share code, notes, and snippets.

@ruccho
ruccho / PersistentSerializedProperty.cs
Last active June 1, 2020 07:31
SerializedPropertyに対して配列操作によるインデックスの変更を追跡し、データの同一性を確保するためのラッパークラス
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace Ruccho.Utilities
{
/// <summary>
@ruccho
ruccho / AutoVersion.cs
Last active May 3, 2020 04:40
Unityで再生ボタンを押すたびにプロジェクトのバージョンを上げるスクリプト。Editorフォルダに入れて使ってください。
using UnityEditor;
using System.Linq;
namespace Ruccho.Utilities
{
public class AutoVersion
{
[InitializeOnLoadMethod]
private static void RegisterEditorIncrementEvent()
using System.Threading;
using UnityEngine;
public class FPSAdjuster : MonoBehaviour
{
[SerializeField, Min(1)]
private int fps;
[SerializeField]
private bool useThreadSleep = false;
@ruccho
ruccho / Fang Preview.lua
Last active February 1, 2020 08:40
A Lua script for Aseprite that shows auto tiling preview for FangAutoTile ( https://assetstore.unity.com/packages/tools/sprite-management/fang-auto-tile-132602 ).
----------------------------------------------------------------------
-- Auto tiling preview for FangAutoTile (https://assetstore.unity.com/packages/tools/sprite-management/fang-auto-tile-132602).
--
-- It works for all color modes (RGB/GRAY/INDEXED).
----------------------------------------------------------------------
if app.apiVersion < 1 then
return app.alert("This script requires Aseprite v1.2.10-beta3")
end
@ruccho
ruccho / EmissiveDissolve.shader
Last active November 29, 2019 17:34
発光+ノイズによるディゾルブエフェクトを行うシェーダー。2D ピクセルパーフェクト対応。Bloomと一緒にお使いください。
Shader "Unlit/EmissiveDissolve"
{
Properties
{
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
_Color("Tint", Color) = (1,1,1,1)
[MaterialToggle] PixelSnap("Pixel snap", Float) = 0
[HideInInspector] _RendererColor("RendererColor", Color) = (1,1,1,1)
[HideInInspector] _Flip("Flip", Vector) = (1,1,1,1)
[PerRendererData] _AlphaTex("External Alpha", 2D) = "white" {}
@ruccho
ruccho / BG_DottedWave.shader
Created October 31, 2019 15:11
背景用シェーダー。Quadとかに貼ってつかってください。
Shader "Unlit/BG_DottedWave"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_UpperColor("Upper Color", Color) = (1.0,1.0,1.0,1.0)
_LowerColor("Lower Color", Color) = (1.0,1.0,1.0,1.0)
_SurfaceHeight("Surface Height", Float) = 0.5
@ruccho
ruccho / DraggableGraphicWithEventTrigger.cs
Last active July 21, 2019 06:54
Unity uGUI要素をドラッグ可能にするスクリプト
using UnityEngine;
using UnityEngine.EventSystems;
[RequireComponent(typeof(EventTrigger))]
public class DraggableGraphicWithEventTrigger : MonoBehaviour
{
//ドラッグ開始地点とこのオブジェクトの原点との差分ベクトル
private Vector2 mouseOffset;
@ruccho
ruccho / PixelOutline.cs
Last active June 16, 2019 15:31
uGUIのアウトラインをドットのフォントでキレイに表示するやつ。Textにアタッチして使えます。
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Ruccho.Utilities
{
public class PixelOutline : Shadow
{
[SerializeField]
private bool EightDirection;
@ruccho
ruccho / Water-R.shader
Last active June 8, 2019 15:12
2D simple water with reflection for Unity. Create empty GameObject with SpriteRenderer and attach the material and the script.
Shader "Effect/Water-R"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_NormalA("Normal A", 2D) = "" {}
_NormalAAmount("Normal A Amount", Range(0,100)) = 50
_NormalASpeed("Normal A Speed", Float) = 1.0
_NormalB("Normal B", 2D) = "" {}
_NormalBAmount("Normal B Amount", Range(0,100)) = 50
@ruccho
ruccho / topmost.hsp
Created May 24, 2019 13:55
HSPでTopMostなウィンドウにするやつ
#include "user32.as"
#define HWND_TOPMOST -1
#define SWP_NOSIZE 0x0001
#define SWP_NOMOVE 0x0002
SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, (SWP_NOMOVE | SWP_NOSIZE)
stop