Skip to content

Instantly share code, notes, and snippets.

@RamType0
RamType0 / UniTaskAsyncGPUReadbackExtensions.cs
Last active December 17, 2020 08:18
ComputeBuffer.GetDataAsyncなどのメソッドを生やすAsyncGPUReadbackのUniTask向け拡張メソッド集。
using System;
using UnityEngine;
using Unity.Collections;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
namespace Cysharp.Threading.Tasks
{
public static class UniTaskAsyncGPUReadbackExtensions
{
@RamType0
RamType0 / UnityYAMLMergeGitConfiguration.ps1
Created October 12, 2020 09:25
Unityのインストール場所に関係なくUnityYAMLMergeをGitで使うためのgitconfigのセットアップを行うPowerShellスクリプト
Param([switch][bool]$system,[switch][bool]$global,[switch][bool]$local)
# --systemでシステム、--globalでユーザー、--localでリポジトリ内を対象として設定を行う。優先順位はlocal>global>system
function SetGitConfig ([ValidateSet('--system','--global','--local')][string]$scope)
{
git config $scope merge.tool unityyamlmerge
git config $scope mergetool.unityyamlmerge.trustExitCode true
git config $scope mergetool.unityyamlmerge.cmd "powershell \`"&(Get-ItemPropertyValue `'HKCU:\Software\Unity Technologies\Installer\Unity' -Name 'Location x64' | Join-Path -ChildPath 'Editor\Data\Tools\UnityYAMLMerge.exe') merge -p `$BASE `$REMOTE `$LOCAL `$MERGED\`""
}
if(-not ($system -or $global -or $local)){
throw "At least one option required."
@RamType0
RamType0 / Wireframe.shader
Created September 8, 2020 13:41
ワイヤーフレームシェーダー
Shader "RamType0/Wireframe"
{
Properties
{
_Color("Color",Color) = (0,1,1,1)
}
SubShader
{
Tags { "RenderType"="Opaque" "Queue" = "AlphaTest+275" }
LOD 100
//clipPos.w = 1, viewPos.z = -1
float2 ClipXYToViewXY(float2 clipXY)
{
//clipXY.xy = mad(1, UNITY_MATRIX_P._m02_m12, clipXY.xy);
clipXY.xy += UNITY_MATRIX_P._m02_m12;
return float2(clipXY.x / UNITY_MATRIX_P._m00, clipXY.y / UNITY_MATRIX_P._m11);
}
float2 InverseTransformStereoScreenSpaceTex(float2 uv, float w)
{
#if UNITY_SINGLE_PASS_STEREO