Skip to content

Instantly share code, notes, and snippets.

View kaiware007's full-sized avatar

kaiware007 kaiware007

View GitHub Profile
@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()
@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 / 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 / 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 / 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 / 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 / startup.cmd
Created June 15, 2018 08:28
Unity Startup Batch 自動再起動、ログファイルを日時でリネーム、10日以上前のログファイル削除機能付き
REM "フォルダ名=appname"
for %%* in (.) do set appname=%%~nx*
if not exist LogBackup/ mkdir LogBackup
REM 10日以上前のログファイル削除
forfiles /P LogBackup /D -10 /M "output_log_*.txt" /c "cmd /c del @file"
:begin
@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 / unicode2utf16.sh
Created July 24, 2018 18:22
unicode番号のbmpファイルの名前をutf-16のファイル名に変更するシェルスクリプト
#!/bin/bash
function convUTF16() {
n=`echo $((0x$1-0x10000))`
nn=$n
if [ $n -lt 0 ]; then
nn=`echo $((0x$1))`
fi
echo $nn
}
@kaiware007
kaiware007 / ScreenAdjustTransform.cs
Last active September 16, 2018 14:41
Orthographicカメラの大きさいっぱいにTransformを拡縮するスクリプト(Unity3D)
using UnityEngine;
public class ScreenAdjustTransform : MonoBehaviour {
public Camera targetCamera = null;
void AdjustScreen()
{
float height = targetCamera.orthographicSize * 2;
float width = height * targetCamera.aspect;