Skip to content

Instantly share code, notes, and snippets.

View kaiware007's full-sized avatar

kaiware007 kaiware007

View GitHub Profile
@kaiware007
kaiware007 / billboard.shader
Created January 19, 2018 09:28
Simple Billboard shader for Unity
Shader "Unlit/Billboard"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" "DisableBatching" = "True" }
@kaiware007
kaiware007 / RenderCubemapWizard.cs
Last active June 22, 2017 04:26
任意の解像度でCubemapを作って保存するEditorスクリプト
// http://docs.unity3d.com/ja/current/ScriptReference/Camera.RenderToCubemap.html
// http://stackoverflow.com/questions/34458622/unity-save-cubemap-to-one-circle-image
using UnityEngine;
using UnityEditor;
using System.Linq;
using System.IO;
public class RenderCubemapWizard : ScriptableWizard
{
@kaiware007
kaiware007 / RenderCubemapWizard.cs
Created June 22, 2017 04:17
Cubemapを作るEditorスクリプト。
// http://docs.unity3d.com/ja/current/ScriptReference/Camera.RenderToCubemap.html
// http://stackoverflow.com/questions/34458622/unity-save-cubemap-to-one-circle-image
using UnityEngine;
using UnityEditor;
using System.Linq;
using System.IO;
public class RenderCubemapWizard : ScriptableWizard
{
@kaiware007
kaiware007 / ShaderDefines.cs
Last active June 25, 2018 07:26
Shaderの変数のIDを起動時に取得するクラス for Unity3D
using UnityEngine;
namespace Utility
{
/// <summary>
/// シェーダー定義
/// </summary>
public static class ShaderDefines
{
public enum TextureID
@kaiware007
kaiware007 / SceneCameraController.cs
Last active April 23, 2023 16:53
GameViewのカメラを、SceneViewのカメラと同じような操作感で動かせるスクリプト for Unity
using UnityEngine;
[RequireComponent(typeof(Camera))]
public class SceneCameraController : MonoBehaviour
{
public Vector3 targetPoint; // 注視点
public float rotateSpeed = 10;
public float translateSpeed = 1;
public float zoomSpeed = 5;
@kaiware007
kaiware007 / Utility.cs
Created May 25, 2017 03:58
数学関係の細々した関数群
using UnityEngine;
namespace KUtil
{
public static class Utility
{
/// <summary>
/// 点Pと線ABの距離を求める
/// </summary>
/// <param name="p"></param>
@kaiware007
kaiware007 / DumpVector3.cs
Created May 22, 2017 16:26
Vector3をファイルに保存する
using System.IO;
using UnityEngine;
public static class Dump
{
public static void DumpVector3(Vector3[] datas, string fileName)
{
StreamWriter sw;
string date = System.DateTime.Now.ToString("yyyyMMddtthhmmss");
string filePath = Application.dataPath + "/../" + fileName + "_" + date + ".txt";
@kaiware007
kaiware007 / RotateTest.cs
Last active April 15, 2017 18:27
トラックボールっぽい回転(慣性付き)
using UnityEngine;
public class RotateTest : MonoBehaviour {
public Vector3 axis = Vector3.up;
public float rotSpeed = 0;
public float power = 0.1f;
public float friction = 0.98f;
public float stickPower = 100;
@kaiware007
kaiware007 / WindowControl.cs
Last active December 17, 2022 23:54
実行中のUnityアプリのウィンドウの位置をマウスやキーボードで動かしたり、タイトルバーを非表示にしたりするスクリプト(Windows only)
using UnityEngine;
using System;
using System.Runtime.InteropServices;
public class WindowControl : MonoBehaviour {
// 参照元
// http://answers.unity3d.com/questions/13523/is-there-a-way-to-set-the-position-of-a-standalone.html
// http://stackoverflow.com/questions/2825528/removing-the-title-bar-of-external-application-using-c-sharp
// https://gist.github.com/mattatz/ca84b487c5697e7d43f8216c57a2b975
@kaiware007
kaiware007 / file0.cs
Created July 5, 2016 07:42
エディットモード中に実行せずに一定時間おきに更新処理を行う方法 ref: http://qiita.com/kaiware007/items/871392e318abafe8b531
#if UNITY_EDITOR
static double waitTime = 0;
void OnEnable()
{
waitTime = EditorApplication.timeSinceStartup;
EditorApplication.update += EditorUpdate;
}
void OnDisable()