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 / Debug.cs
Last active October 24, 2018 09:55
条件付きのUnityEngine.Debugクラス
#if DEBUG_OVERWRAP
using UnityEngine;
using System.Diagnostics;
using UnityDebug = UnityEngine.Debug;
using UnityObject = UnityEngine.Object;
/// <summary>
/// 条件付きのUnityEngine.Debugクラス
/// </summary>
@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)
@mao-test-h
mao-test-h / AbeHirosh_HP_Window.cs
Last active September 3, 2019 16:30
阿部寛のホームページを表示するためのEditor拡張 ※Unity2017.2.0p1で動作確認
using System.Reflection;
using UnityEditor;
/// <summary>
/// 阿部寛のホームページを表示するためのEditor拡張
/// </summary>
public static class AbeHirosh_HP_Window
{
[MenuItem(@"Window/阿部寛のホームページ")]
static void Open()
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
{