Skip to content

Instantly share code, notes, and snippets.

@mao-test-h
mao-test-h / RotateCubeTest.cs
Created June 4, 2017 04:14
Cubeを接地した状態で回転させる方法について
using System.Collections;
using UnityEngine;
public class RotateCubeTest : MonoBehaviour
{
const float RotatingSpeed = 0.2f;
const float RotatingAngle = 90f;
Vector3 halfSize;
float time = 0f;
Vector3 axis = Vector3.zero;
@mao-test-h
mao-test-h / Singleton.cs
Created July 26, 2017 03:03
Unity向け シングルトン基底クラス(MonoBehaviour非継承)
namespace Singleton
{
/// <summary>
/// シングルトン基底クラス(MonoBehaviour非継承)
/// </summary>
public abstract class Singleton<T> where T : class, new()
{
public static readonly T Instance = new T();
}
}
@mao-test-h
mao-test-h / SingletonMonoBehaviour.cs
Created July 26, 2017 03:05
Unity向け シングルトン基底クラス(MonoBehaviour継承)
using UnityEngine;
namespace Singleton
{
/// <summary>
/// シングルトン基底クラス(MonoBehaviour継承)
/// </summary>
public abstract class SingletonMonoBehaviour<T> : MonoBehaviour where T : SingletonMonoBehaviour<T>
{
static T instance;
@mao-test-h
mao-test-h / Dokaben-Sprite-Default.shader
Last active October 24, 2017 19:44
ドカベンロゴアニメーションシェーダー ※Unity2017.2.0f3の"Sprites/Default"をベースに作成
// "Sprites/Default"のドカベンロゴアニメーション版
Shader "Dokaben/Sprites/Title-Animation"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
[HideInInspector] _RendererColor ("RendererColor", Color) = (1,1,1,1)
class Object
{
float _mass;
PVector _location;
PVector _velocity;
PVector _acceleration;
float _G;
Object(float mass, float x, float y)
{
@mao-test-h
mao-test-h / ProcessingClothTest.pde
Created January 17, 2018 16:58
Processingで布っぽいのを実装(Nature of Code : Chapter5参照)
// Nature of Code : Chapter5 参照
import toxi.physics2d.behaviors.*;
import toxi.physics2d.*;
import toxi.geom.*;
import toxi.math.*;
VerletPhysics2D physics;
Blanket blanket;
@mao-test-h
mao-test-h / WorleyNoise.shader
Created April 19, 2018 16:40
ShaderLabでのWorleyNoiseの実装
// 参考サイト
// ・セルラーノイズ
// https://thebookofshaders.com/12/?lan=jp
Shader "Custom/WorleyNoise"
{
CGINCLUDE
#include "UnityCG.cginc"
float2 random2(fixed2 st)
@mao-test-h
mao-test-h / InspectorArraySortTest.cs
Last active July 5, 2018 21:59
【Unity】Inspectorに表示されている配列の要素をソートするサンプル
// Inspectorに表示されている配列の要素をソートするサンプル
namespace MainContents.Test
{
using UnityEngine;
using System.Collections;
[CreateAssetMenu(menuName = "ScriptableObjects/InspectorArraySortTest", fileName = "InspectorArraySortTest")]
public class InspectorArraySortTest : ScriptableObject
{
@mao-test-h
mao-test-h / CosApproximate.cs
Last active August 1, 2018 17:02
級数展開でcosの近似値を出すテスト
// https://twitter.com/TEST_H_/status/1023975602494169092
using System;
using System.Diagnostics;
namespace MyContents
{
class Test
{
static void Main()
@mao-test-h
mao-test-h / AudioCueSample.cs
Last active August 4, 2018 16:50
Unity用SoundCue(っぽいもの)サンプル
namespace MainContents.AudioUtility
{
using UnityEngine;
// UE4のSoundCueを参考にしたもの。
// 内容的にはAudioClipのラッパー的な立ち位置で、AudioClipを取得する際の振る舞いを実装するもの。
// →例 : ランダムでClipを返すもの、配列に登録したClipを順番に取得など。
// ※本当はinterfaceにしたいけどSerializeFieldで登録する都合上、敢えて基底クラスとする...
public abstract class AudioCue : ScriptableObject
{