Skip to content

Instantly share code, notes, and snippets.

View kodai100's full-sized avatar

Kodai Takao kodai100

View GitHub Profile
@kodai100
kodai100 / AutoImportRequiredPackages.cs
Created February 27, 2021 20:00
エディタ起動(コンパイル)時に自動でPackageManagerの指定パッケージをインストールさせるエディタスクリプト
[InitializeOnLoad]
public static class AutoImportRequiredPackages
{
static readonly List<string> requiredPackageList = new List<string>()
{
"com.unity.visualeffectgraph@10.2.2",
"com.unity.render-pipelines.universal@10.2.2",
"com.unity.inputsystem@1.0.2"
};
@kodai100
kodai100 / .gitattributes
Created July 6, 2020 06:21
Unity Gitattributes
## Unity ##
*.cs diff=csharp text
*.cginc text
*.shader text
*.mat merge=unityyamlmerge eol=lf
*.anim filter=lfs diff=lfs merge=lfs -text
*.unity merge=unityyamlmerge eol=lf
*.physicsMaterial2D merge=unityyamlmerge eol=lf
*.physicsMaterial merge=unityyamlmerge eol=lf
*.asset merge=unityyamlmerge eol=lf
@kodai100
kodai100 / TransformExtension.cs
Last active October 19, 2019 14:32
Find Deep Child as transform.FirstChildOrDefault(trans => trans.name == "name")
using System;
using UnityEngine;
public static class TransformExtension
{
public static Transform FirstChildOrDefault(this Transform parent, Func<Transform, bool> query)
{
Transform result = null;
if (query(parent))
@kodai100
kodai100 / ExchangeRate.cs
Created May 25, 2019 16:40
Exchange Rate Calculator (Unity)
using UnityEngine;
using UniRx.Async;
using SimpleJSON;
using UnityEngine.Networking;
public enum Currency
{
BGN, NZD, ILS, RUB, CAD, USD, PHP, CHF, AUD, JPY, TRY, HKD, MYR, HRK, CZK, IDR, DKK,
NOK, HUF, GBP, MXN, THB, ISK, ZAR, BRL, SGD, PLN, INR, KRW, RON, CNY, SEK, EUR
}
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using UnityEngine.Networking;
using UniRx.Async;
public class FileWatcher : MonoBehaviour
{
static readonly string watchFolderPath = Application.streamingAssetsPath;
@kodai100
kodai100 / DissappearablePositiveX.shader
Created March 15, 2019 09:00
# 指定のx位置より右側にある部分が消えるSurfaceシェーダー
Shader "Custom/DissappearablePositiveX"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_DissolvePosition("Dissolve Position", Range(0, 1000)) = 0
}
//
// Transparent unlit shader for Spray
//
// Vertex format:
// position.xyz = vertex position
// texcoord.xy = uv for GPGPU buffers
//
// Position buffer format:
// .xyz = particle position
// .w = life (+0.5 -> -0.5)
@kodai100
kodai100 / SimpleUnlit.shader
Created July 18, 2018 17:17
Simple Unlit Shader
Shader "Custom/SimpleUnlit" {
Properties{
_Aspect("Aspect Ratio", Float) = 1.66
}
SubShader{
LOD 200
CGINCLUDE
@kodai100
kodai100 / FrameCapturer.cpp
Last active February 1, 2018 17:44
Frame caputurer for GLFW (with FreeImage)
#pragma once
#include <string>
#include <GLFW\glfw3.h>
#include <FreeImage\FreeImage.h>
using namespace std;
class FrameCapturer {
private:
@kodai100
kodai100 / GLFWWindowCentering.cpp
Created January 30, 2018 06:39
For centering GLFW window
void centering(GLFWwindow* window) {
// Get screen resolution
const GLFWvidmode * mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
int screen_width = mode->width, screen_height = mode->height;
int halfx = screen_width / 2, halfy = screen_height / 2;
int hw = WIN_SIZE_X / 2, hh = WIN_SIZE_Y / 2;
int posx = halfx - hw, posy = halfy - hh;