Skip to content

Instantly share code, notes, and snippets.

View Santarh's full-sized avatar

Masataka SUMI Santarh

  • Tokyo, Japan
View GitHub Profile
@Santarh
Santarh / SaveTexture.cs
Created January 20, 2020 17:27
[Unity] Get PNG bytes from RenderTexture with Color Conversion.
using UnityEngine;
public class SaveTexture : MonoBehaviour
{
private byte[] SaveRenderTextureAsPng(RenderTexture rt)
{
if (rt == null || !rt.IsCreated()) return null;
// Allocate
@Santarh
Santarh / CameraExtensions.cs
Last active November 29, 2019 20:23
Get 35mm Focal Length in Unity
using UnityEngine;
namespace Utils
{
public static class CameraExtensions
{
private static readonly float HalfDiagonalOf35Millimeter = Mathf.Sqrt(36 * 36 + 24 * 24) * 0.5f;
public static float Get35MillimeterFocalLength(this Camera camera)
{
using UnityEngine;
using UnityEngine.Rendering;
public class AAA : MonoBehaviour
{
[SerializeField] private Mesh _mesh;
[SerializeField] private Material _material;
private Matrix4x4[] _matrices;
private void OnEnable()
@Santarh
Santarh / MyTemplate.shader
Created December 24, 2017 12:35
Unity Shader Template
Shader "SantarhTemplate"
{
Properties
{
}
SubShader
{
Tags { "RenderType" = "Opaque" "Queue" = "Geometry" }
# This example assumes we have a mesh object in edit-mode
import bpy
import bmesh
from mathutils import Vector
# Get the active mesh
obj = bpy.context.edit_object
me = obj.data
using UnityEngine;
public class Foo
{
private readonly int _hoge;
public Foo(GameObject target, int hoge)
{
_hoge = hoge;
target.AddComponent<FooBehaviour>().Init(this);
@Santarh
Santarh / ConvertEncoding.cs
Last active January 1, 2016 23:39
Converting character encoding on C#
using System;
using System.IO;
using System.Text;
public class Test
{
public static void Main()
{
// your code goes here
string str_unicode = "あいうえお"; // (あ)0x3042, (い)0x3044 ...
@Santarh
Santarh / pixiv.rb
Created July 15, 2013 09:32
Stats of pixiv bookmark's tag
#!/usr/local/bin/ruby
# -*- encoding: utf-8 -*-
require "rubygems"
require "mechanize"
class Pixiv
attr_accessor :agent
attr_accessor :my_id
#!/usr/local/bin/ruby
# -*- encoding: utf-8 -*-
require "rubygems"
require "mechanize"
class Pixiv
attr_accessor :agent
def initialize
@Santarh
Santarh / alc.rb
Created December 9, 2012 18:01
Dictionary Search Command
#!/usr/local/bin/ruby
require "rubygems"
require "mechanize"
require "termcolor"
class Mean
attr_reader :text
def initialize word_class, text
@word_class = word_class