Skip to content

Instantly share code, notes, and snippets.

View GOROman's full-sized avatar
😀
Good

GOROman GOROman

😀
Good
  • XVI Inc.
  • Japan
  • 22:22 (UTC +09:00)
  • X @GOROman
View GitHub Profile
@GOROman
GOROman / Serialize.cs
Last active March 16, 2020 07:16
Unityで構造体をセーブ・ロード(XMLにシリアライズ)
using UnityEngine;
using System.Collections;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
// 保存したい構造体
[System.Serializable]
public struct Param
@GOROman
GOROman / SetPositionY
Created September 14, 2014 15:37
配管工のオッサンをスタート時にTerrainに合わせよう
using UnityEngine;
using System.Collections;
public class SetPositionY : MonoBehaviour {
void Start () {
// スタート時のワールド座標での位置を取得
Vector3 pos = transform.position;
// 位置からTerrain上の高さを取得
@GOROman
GOROman / GoogleGlassMirrorAPI.rb
Created January 24, 2015 14:37
Google Glass へ好きなメッセージ通知する (Mirror API使用)
#!ruby -Ku
# Google Glass へメッセージ通知 (Mirror API)
# by GOROman
require 'net/http'
require 'json'
# OAuthで得たトークン
TOKEN = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
API = 'https://www.googleapis.com/mirror/v1/timeline'
@GOROman
GOROman / GoProSample.cs
Created January 25, 2015 06:53
GoProをC#からWifi経由で制御するサンプルプログラム
// https://github.com/r1pper/GoPro.Hero を使用
using System;
using GoPro.Hero;
using GoPro.Hero.Hero3;
namespace ConsoleApplication1
{
class Program
{
@GOROman
GOROman / GoProControl.rb
Created January 25, 2015 07:04
Wifi接続したGoProをRubyから制御するサンプル
#!ruby -Ku
# Wifi接続したGoProをRubyから制御するサンプル
# by GOROman
require 'net/http'
class GoProControl
def initialize( host )
@http = Net::HTTP.new( host )
@GOROman
GOROman / wlan.bat
Created January 25, 2015 08:25
WindowsのコマンドプロンプトからWLANの接続先を変更する
echo off
netsh WLAN connect name="GoProHero1" ssid="GoProHero1"
pause
netsh WLAN connect name="GoProHero2" ssid="GoProHero2"
pause
netsh WLAN connect name="GoProHero3" ssid="GoProHero3"
@GOROman
GOROman / SetAndroidVolume
Created July 31, 2015 05:26
UnityのC#からAndroidのボリュームを変更する
void SetAndroidVolume( int volume )
{
#if (UNITY_ANDROID && !UNITY_EDITOR)
int STREAM_MUSIC = 3; // Constant Value: 3 (0x00000003)
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject ac = jc.GetStatic<AndroidJavaObject>("currentActivity");
AndroidJavaObject am = ac.Call<AndroidJavaObject>("getSystemService", "audio");
am.Call("setStreamVolume", STREAM_MUSIC, volume, 0);
// UnityからAndroidのCamera LEDを制御する例
// startPreview() でカメラのプレビューを開始した状態で LEDOn() で光る
public class AndroidCamera {
AndroidJavaObject camera = null;
public AndroidCamera() {
WebCamDevice[] devices = WebCamTexture.devices;
Debug.Log("Camera Name:"+devices[0].name);
@GOROman
GOROman / GetSSID.cs
Last active November 11, 2020 08:33
UnityからAndroidのWifi情報を得る(SSIDとか)
// AndroidManifest.xml に <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> の設定が必要
string GetSSID()
{
string ssid = "N/A";
using (var activity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic<AndroidJavaObject>("currentActivity")) {
var wifiManager = activity.Call<AndroidJavaObject>("getSystemService", "wifi");
ssid = wifiManager.Call<AndroidJavaObject>("getConnectionInfo").Call<string>("getSSID");
}
@GOROman
GOROman / ThetaStartSession.rb
Created September 21, 2015 03:38
RubyでTHETA Sへセッションを貼るだけの例
require 'net/http'
HOST = '192.168.1.1'
PORT = 80
Net::HTTP.start(HOST, PORT) do |http|
req = Net::HTTP::Post.new '/osc/commands/execute'
req.body = <<EOF
{