Skip to content

Instantly share code, notes, and snippets.

View blue0513's full-sized avatar
🤩
Always Happy Boy

Taiju Aoki blue0513

🤩
Always Happy Boy
View GitHub Profile
@blue0513
blue0513 / walkDetector.cs
Last active January 13, 2018 15:16
WalkDetector for Unity
// Use it with GyroManager
// https://gist.github.com/blue0513/36443a54a852ba997ebbe274065ab647
using UnityEngine;
using System.Collections;
public class WalkDetector : MonoBehaviour {
private Vector3 acc;
private float[] walk;
@blue0513
blue0513 / GyroManager.cs
Created January 13, 2018 15:15
GyroManager for Unity
using UnityEngine;
using System.Collections;
public class GyroManager : MonoBehaviour {
static bool gyroBool = false;
private Gyroscope gyro;
private Quaternion quatMult;
private GameObject camParent;
// WalkDetectorで参照する
@blue0513
blue0513 / ImagesLoader.cs
Created January 13, 2018 15:26
Load Images Sequentially for Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Load Images from start to end
public class ImagesLoader : MonoBehaviour {
// index for images
private int imageIndex=0;
// number of images to load
private int numberOfImages;
@blue0513
blue0513 / LogWriter.cs
Created January 13, 2018 15:35
Log Writer for Unity
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
public class LogWriter : MonoBehaviour {
private float timer = 0f;
private float logSpan = 1f;
// log path
private string storedFilePath = "";
@blue0513
blue0513 / StandbyDirector.cs
Created January 13, 2018 15:40
Especially for iPad, it detects whether the device is moving or not
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Especially for iPad
public class StandbyDirector : MonoBehaviour {
private Vector3 acc = Vector3.zero;
private Vector3 oldacc = Vector3.zero;
private float timer = 0f;
private bool isFinished = false;
@blue0513
blue0513 / ObjectPropertyDirector.cs
Created January 13, 2018 15:53
Set GameObject Property (Pos, Rot, Size) with Lerp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Set Object Property (Pos, Rot, Size) with Lerp
public class ObjectPropertyDirector : MonoBehaviour {
private Vector3 modifyAngles (Vector3 rot) {
rot.x = modifyAngle (rot.x);
rot.y = modifyAngle (rot.y);
@blue0513
blue0513 / ReadSettingsFromServer.cs
Created January 15, 2018 10:56
read csv setting file in remote server
using UnityEngine;
using System.Collections;
using System.IO;
using System.Collections.Generic;
using System;
public class ReadSettingsFromServer : MonoBehaviour {
// 設定格納用Dictionary
public static Dictionary<string, string> Setting;
private string[] paralist;
@blue0513
blue0513 / PostDataToServer.cs
Last active January 16, 2018 05:24
Post local csv data to remote server
using UnityEngine;
using System.Collections;
using System.IO;
// use it with uploader php
// https://gist.github.com/blue0513/7f772c0ad1e78903a3839e78bffbba0a
public class PostDataToServer : MonoBehaviour {
private string folderPath = "/Data";
private string phpUrl = "http://foo/bar/upload.php"
@blue0513
blue0513 / upload_data.php
Created January 16, 2018 05:23
upload data from unity to server
<?php
if(isset($_FILES['theFile'])) {
$uploaddir = "YOUR DATA PATH";
$uploadfile = $uploaddir . basename($_FILES['theFile']['name']);
if(move_uploaded_file($_FILES['theFile']['tmp_name'], $uploadfile)){;
echo "success";
}
} else {
@blue0513
blue0513 / gitlab-mr-from-commit.sh
Created May 20, 2018 05:51
gitlab-mr-from-commit
#!/bin/bash
# NOTE: Get it from gitlab
PRIVATE_TOKEN='[YOUR PRIVATE TOKEN]'
# NOTE: Get it from your project's setting page
PROJECT_ID='[YOUR PROJECT ID]'
# NOTE: URL should start from `[https|http]://`
PROJECT_URL=$(git config remote.origin.url | cut -f2 | rev | cut -c 5- | rev)