Skip to content

Instantly share code, notes, and snippets.

View kodai100's full-sized avatar

Kodai Takao kodai100

View GitHub Profile
// Draw wireframe preserving triangle primitive.
using UnityEngine;
using System.Collections;
public class WireModel : MonoBehaviour
{
Mesh mesh;
// Use this for initialization
@kodai100
kodai100 / Matrix2x2.cs
Last active July 14, 2025 20:03
Matrix2x2 for Unity
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class Matrix2x2 {
public float m00, m01, m10, m11;
@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;
@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 / 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
//
// 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 / 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
}
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 / 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
}
@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))