34
edits
| m (→Processing:  formatting) | m (→Unity:   formatting) | ||
| Line 73: | Line 73: | ||
| <br> | <br> | ||
| Public values are adjustable without any coding; just use the inspector for that. <br>< | Public values are adjustable without any coding; just use the inspector for that. <br> | ||
| public var RemoteIP : String = ""; | <source lang="javascript"> | ||
| public var SendToPort : int = xxxx; | public var RemoteIP : String = ""; | ||
| public var ListenerPort : int = yyyy; | public var SendToPort : int = xxxx; | ||
| public var controller : Transform; | public var ListenerPort : int = yyyy; | ||
| public var gameReceiver = "Cube";</ | public var controller : Transform; | ||
| In the Start() function all the necessary scripts and components are connected. This will happen once you press Play. <br>< | public var gameReceiver = "Cube"; | ||
| public function Start () | </source> | ||
| { | In the Start() function all the necessary scripts and components are connected. This will happen once you press Play. <br> | ||
| var udp : UDPPacketIO = GetComponent("UDPPacketIO"); | <source lang="javascript"> | ||
| udp.init(RemoteIP, SendToPort, ListenerPort); | public function Start () | ||
| handler = GetComponent("Osc"); | { | ||
| handler.init(udp); |  var udp : UDPPacketIO = GetComponent("UDPPacketIO"); | ||
| handler.SetAllMessageHandler(AllMessageHandler); |  udp.init(RemoteIP, SendToPort, ListenerPort); | ||
| }</ |  handler = GetComponent("Osc"); | ||
| The AllMessageHandler() function is where the Osc happens. This function unpacks the Osc signals, so you can address them in other functions. In this function you can command, whenever A happens, you want FunctionB() to be executed. <br>< |  handler.init(udp); | ||
| public function AllMessageHandler(oscMessage: OscMessage){ |  handler.SetAllMessageHandler(AllMessageHandler); | ||
| var msgString = Osc.OscMessageToString(oscMessage); | } | ||
| var msgAddress = oscMessage.Address; | </source> | ||
| var msgValue = oscMessage.Values[0];</ | The AllMessageHandler() function is where the Osc happens. This function unpacks the Osc signals, so you can address them in other functions. In this function you can command, whenever A happens, you want FunctionB() to be executed. <br> | ||
| So you typed all that code and there are no errors but that stupid thing still won't do what it should - try Debug.Logs! Just add them everywhere! They can tell you what parts of your script are accessed after you press Play. <br>< | <source lang="javascript"> | ||
| Debug.Log("Stakkars meg, som har skrevet 50 Debug.Logs");<br></ | public function AllMessageHandler(oscMessage: OscMessage){ | ||
| The lines will be written in the console section of Unity once they are accessed.<br>   |  var msgString = Osc.OscMessageToString(oscMessage); | ||
|  var msgAddress = oscMessage.Address; | |||
|  var msgValue = oscMessage.Values[0]; | |||
| </source> | |||
| So you typed all that code and there are no errors but that stupid thing still won't do what it should - try Debug.Logs! Just add them everywhere! They can tell you what parts of your script are accessed after you press Play. <br> | |||
| <source lang="javascript"> | |||
| Debug.Log("Stakkars meg, som har skrevet 50 Debug.Logs");<br> | |||
| </source> | |||
| The lines will be written in the console section of Unity once they are accessed.<br><br>   | |||
| [[File:50Debug_Logs.png]] | [[File:50Debug_Logs.png]] | ||
edits