Here you go:
Make sure you rename your wiimote.cs to WiiMote.cs (Won’t compile if the name is different to the class inside)
Here’s bullet.js, attach to whatever you like, click in the inspector and change the target to the object containing the wiimote script:
import System;
var myX: int=6;
var myY: int=6;
var target : Transform;
function Start()
{
var wm = target.gameObject.GetComponent(WiiMote);
Debug.Log("Cursor x = "+wm.cursorX+" Cursor y = "+wm.cursorY);
myX = wm.cursorX;
myY = wm.cursorY;
Debug.Log("myX = "+myX+" myY = "+myY);
wm.CommsTest();
}
I’ve put some confirmation debug info in there and I run a Dummy function that you can put into the wiimote cs to output that the js has found it… just replace the wiimote script with the following:
using UnityEngine;
using System;
using System.Collections;
using System.Runtime.InteropServices;
public class WiiMote : MonoBehaviour {
[DllImport ("UniWii")]
private static extern void wiimote_start();
[DllImport ("UniWii")]
private static extern void wiimote_stop();
[DllImport ("UniWii")]
private static extern int wiimote_count();
[DllImport ("UniWii")]
private static extern byte wiimote_getAccX(int which);
[DllImport ("UniWii")]
private static extern byte wiimote_getAccY(int which);
[DllImport ("UniWii")]
private static extern byte wiimote_getAccZ(int which);
[DllImport ("UniWii")]
public static extern float wiimote_getIrX(int which);
[DllImport ("UniWii")]
public static extern float wiimote_getIrY(int which);
[DllImport ("UniWii")]
private static extern float wiimote_getRoll(int which);
[DllImport ("UniWii")]
private static extern float wiimote_getPitch(int which);
[DllImport ("UniWii")]
private static extern float wiimote_getYaw(int which);
private string display;
public int cursorX =5;
public int cursorY =5;
private Texture2D cursor_tex;
private Vector3 oldVec;
// Use this for initialization
void Start () {
wiimote_start();
cursor_tex = (Texture2D) Resources.Load("crosshair");
}
// Update is called once per frame
void FixedUpdate () {
int c = wiimote_count();
if (c>0) {
display = "";
for (int i=0; i<=c-1; i++) {
int x = wiimote_getAccX(i);
int y = wiimote_getAccY(i);
int z = wiimote_getAccZ(i);
float roll = Mathf.Round(wiimote_getRoll(i));
float p = Mathf.Round(wiimote_getPitch(i));
float yaw = Mathf.Round(wiimote_getYaw(i));
float ir_x = wiimote_getIrX(i);
float ir_y = wiimote_getIrY(i);
display += "Wiimote " + i + " accX: " + x + " accY: " + y + " accZ: " + z + " roll: " + roll + " pitch: " + p + " yaw: " + yaw + " IR X: " + ir_x + " IR Y: " + ir_y + "\n";
if (!float.IsNaN(roll) !float.IsNaN(p) (i==c-1)) {
Vector3 vec = new Vector3(p, 0 , -1 * roll);
vec = Vector3.Lerp(oldVec, vec, Time.deltaTime * 5);
oldVec = vec;
// GameObject.Find("wiiparent").transform.eulerAngles = vec;
}
if ( (i==c-1) (ir_x != -100) (ir_y != -100) ) {
//float temp_x = ((ir_x + (float) 1.0)/ (float)2.0) * (float) Screen.width;
//float temp_y = (float) Screen.height - (((ir_y + (float) 1.0)/ (float)2.0) * (float) Screen.height);
float temp_x = ( Screen.width / 2) + ir_x * (float) Screen.width / (float)2.0;
float temp_y = Screen.height - (ir_y * (float) Screen.height / (float)2.0);
cursorX = Mathf.RoundToInt(temp_x);
cursorY = Mathf.RoundToInt(temp_y);
}
}
}
else display = "Press the '1' and '2' buttons on your Wii Remote.";
}
void OnApplicationQuit() {
wiimote_stop();
}
void OnGUI() {
GUI.Label( new Rect(10,10, 500, 100), display);
if ((cursorX != 0) || (cursorY != 0)) GUI.Box ( new Rect (cursorX, cursorY, 50, 50), cursor_tex); //"Pointing\nHere");
int c = wiimote_count();
for (int i=0; i<=c-1; i++) {
float ir_x = wiimote_getIrX(i);
float ir_y = wiimote_getIrY(i);
if ( (ir_x != -100) (ir_y != -100) ) {
float temp_x = ((ir_x + (float) 1.0)/ (float)2.0) * (float) Screen.width;
float temp_y = (float) Screen.height - (((ir_y + (float) 1.0)/ (float)2.0) * (float) Screen.height);
temp_x = Mathf.RoundToInt(temp_x);
temp_y = Mathf.RoundToInt(temp_y);
//if ((cursor_x != 0) || (cursor_y != 0))
GUI.Box ( new Rect (temp_x, temp_y, 64, 64), "Pointer " + i);
}
}
}
public void CommsTest(){
Debug.Log("Vars recieved!");
}
}
I’ve deliberately changed the cursor_x and _y for cursorX and cursorY just while I was testing, won’t make any difference to you calling them from elsewhere.
Now anytime you want to access WiiMote script from within bullet.js just use wm.functionname or wm.var to either read or wrtie the script 
I always find it a pain to set this up unless the scripts areon camera.main or the same object as each other, but this works (as long as you set which object has the script on it)
Oh and feel free to change myX and myY to 0 ditto for cursorX and Y (I did it to watch the values change in the inspector, since I don’t have a wiimote hooked up :lol:)