Skip to content

Instantly share code, notes, and snippets.

@fuqunaga
fuqunaga / PingObjectShortcut.cs
Created June 13, 2023 08:24
PingObjectShortcut
using UnityEditor;
using UnityEngine;
public static class PingObjectShortcut
{
private const string MenuPath = "Tools/Ping/";
[MenuItem(MenuPath + "MainCamera #&c")]
private static void PingMainCamera()
{
@fuqunaga
fuqunaga / GrabColorRendererFeature.cs
Last active November 20, 2023 07:50
GrabColorRendererFeature
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
/// <summary>
/// Built-in Render PipelineのGrabPassに近いRendererFeature
/// RenderObjectsRendererFeatureでGrab対象のオブジェクトを描画し、
/// そのあとにGrabColorRendererFeatureを設定することで任意のタイミングでキャプチャ、
/// 以降のシェーダーでgrabbedTextureNameで指定した名前でキャプチャしたテクスチャを参照できる
///
@fuqunaga
fuqunaga / SampleComponent.cs
Last active June 9, 2022 06:52
Comparison of GetComponent() and TryGetComponent()
using UnityEngine;
public class SampleComponent : MonoBehaviour
{
public int value;
}
@fuqunaga
fuqunaga / README.md
Last active May 25, 2020 08:08
Visualize normals of Skinned Mesh Renderer in Unity3D
@fuqunaga
fuqunaga / MeshToMap.cs
Last active December 19, 2019 07:35
vtx to texture
static Texture2D MeshToMap(Mesh mesh)
{
var vertices = mesh.vertices;
var count = vertices.Count();
float r = Mathf.Sqrt(count);
var width = (int)Mathf.Ceil(r);
var height = width;
var positions = vertices.Select(vtx => new Color(vtx.x, vtx.y, vtx.z));
ffmpeg -i input.mov -filter_complex "[0:v] split [a][b];[a] palettegen [p];[b][p] paletteuse" output-palette.gif
@fuqunaga
fuqunaga / SceneCameraController.cs
Last active August 23, 2023 06:16 — forked from kaiware007/SceneCameraController.cs
GameViewのカメラを、SceneViewのカメラと同じような操作感で動かせるスクリプト for Unity
using UnityEngine;
[RequireComponent(typeof(Camera))]
public class SceneCameraController : MonoBehaviour
{
public Vector3 targetPoint; // 注視点
public float rotateSpeed = 10;
public float translateSpeed = 1;
public float zoomSpeed = 5;
@fuqunaga
fuqunaga / JsonUtilityEx.cs
Last active June 1, 2023 15:43
JsonUtility exntention. support primitive type, List and Array
using System;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// JsonUtility extension.
/// support primitive type, List and Array
///
/// https://gist.github.com/fuqunaga/b50b49cc08010ba37b07ac01c401a8f0
vec2 rand2n() {
seed+=vec2(-1,1);
// implementation based on: lumina.sourceforge.net/Tutorials/Noise.html
return vec2(fract(sin(dot(seed.xy ,vec2(12.9898,78.233))) * 43758.5453),
fract(cos(dot(seed.xy ,vec2(4.898,7.23))) * 23421.631));
};
@fuqunaga
fuqunaga / DitherTransparency.shader
Last active February 25, 2019 08:22
DitherTransparency with BayerMatrix
Shader "Unlit/DitherTransparency"
{
Properties
{
_Color("Color", Color) = (1,1,1,1)
_Alpha("Alpha", Range(0,1))=1
}
SubShader
{
Tags { "RenderType"="Opaque" }