LoginSignup
0
0

More than 1 year has passed since last update.

UnityOSC

Last updated at Posted at 2016-08-27

UnityでOSCをしてみる

UnityとMaxの連携をしてみる。

##1.UnityOSCをダウンロード

##2.UnityにUnityOSCをいれる
Assets直下にUnityOSC/srcをドラッグ&ドロップ。

##3.OSCController.CSフォルダをつくる
Assets直下に。

OSCController.CS

using UnityEngine;
using System.Collections;

public class OSCController : MonoBehaviour {
	public string serverId = "max";
	public string serverIp = "172.20.10.3";
	public int    serverPort = 12000;

	public KeyCode debugKey = KeyCode.S;
	public string  debugMessage = "/sample";

	// Use this for initialization
	void Start () {
		OSCHandler.Instance.Init(this.serverId, this.serverIp, serverPort);
	}
	
	// Update is called once per frame
	void Update () {
		if (Input.GetKeyDown(this.debugKey))
		{
			OSCHandler.Instance.SendMessageToClient
			(this.serverId, this.debugMessage, Time.timeSinceLevelLoad);
		}
	}
}

##4.OSCHandler.CSの一部を書き換える

OSCHandler.C

...

public void Init(string serverId, string serverIp, int serverPort)
	{
        //Initialize OSC clients (transmitters)
        //Example:		
		CreateClient(serverId, IPAddress.Parse(serverIp), serverPort);

        //Initialize OSC servers (listeners)
        //Example:

        //CreateServer("AndroidPhone", 6666);
	}

...

##5.Max

スクリーンショット 2016-08-25 19.37.48.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0