iTween and External Variables

I have a camera object called CameraView. This object has two JS scripts attached to it called scene_Gizmos.js and cameraMode.js

cameraMode.js has 49 GameObject arrays that are used to house waypoints for motion paths. I am attempting to access those arrays from scene_Gizmos.js so that I can draw the paths in the Scene View. I am attempting to access the data like this:

var WP_list;
WP_list = GetComponents(cameraMode);

That seems to work. So now in theory I have access to all 49 path arrays. Now I attempt to draw the paths using iTween.DrawPath, and this is where I run into problems. I am obviously using this wrong, I’m just not sure how.

// WP_start_docks is a GameObject[] in cameraMode.js
iTween.DrawPath(WP_list.WP_start_docks);

I’ve attempted several different ways of passing an array of GameObjects to this method but without success. Any help would be much appreciated

What does the declaration of WP_start_docks look like? In fact, just post cameraMode.js if possible.
Is it one of the 49 arrays, or is it itself an array of 49 arrays?

iTween.DrawPath expects an array (as in, built-in array, not the Array class) of either Vector3 or Transform. If your list is anything other than that (such as an array of GameObjects), it won’t work.

It is 1 array out of 49 arrays.

Would I need to the variable from an array GameObjects to an array of Vector3 or Transforms?

iTween website says this :
When called from an OnDrawGizmos() function it will draw a curved path through the provided array of Vector3 or Transforms.
The phrasing here made me think it was an array of either Type. Am I wrong?

DrawPath(Vector3[ ] path)
or
DrawPathGizmos(Transform[ ] path)

var mode : int;
var labelStyle : GUIStyle;

//** CAMERA ORBIT VARIABLES //**
// Camera Orbit Speeds
var charCamera : Transform;
//var floatCamera : boolean = true;
var zoomSensitivity : float = 5.0;

// Camera Position
var camDistance : float = 0.0;
var camHeight : float = 0.0;

// Camera Orbit Speeds
var rotateSens : float = 1.0;
var wheelSpeed : float = 5.0;

private var zoomMin : float = -2.0;
private var zoomMax : float = -20.0;
private var orbitMin : float = -10.0;
private var orbitMax : float = 10.0;
private var x = 0.0;
private var y = 0.0;

// Zoom senstivity clamps
private var zSenMin : float = 1.0;
private var zSenMax : float = 10.0;
/**///////////////////////////**

// WP : From Start 
var WP_start_quarry : GameObject[];
var WP_start_workshop : GameObject[];
var WP_start_arena : GameObject[];
var WP_start_statue : GameObject[];
var WP_start_library : GameObject[];
var WP_start_temple : GameObject[];
var WP_start_docks : GameObject[];
// WP : From Quarry
var WP_quarry_workshop : GameObject[];
var WP_quarry_arena : GameObject[];
var WP_quarry_statue : GameObject[];
var WP_quarry_library : GameObject[];
var WP_quarry_temple : GameObject[];
var WP_quarry_docks : GameObject[];
// WP : From Arena
var WP_arena_quarry : GameObject[];
var WP_arena_workshop : GameObject[];
var WP_arena_statue : GameObject[];
var WP_arena_library : GameObject[];
var WP_arena_temple : GameObject[];
var WP_arena_docks : GameObject[];
// WP : From Workshop
var WP_workshop_quarry : GameObject[];
var WP_workshop_arena : GameObject[];
var WP_workshop_statue : GameObject[];
var WP_workshop_library : GameObject[];
var WP_workshop_temple : GameObject[];
var WP_workshop_docks : GameObject[];
// WP : From Statue
var WP_statue_quarry : GameObject[];
var WP_statue_workshop : GameObject[];
var WP_statue_arena : GameObject[];
var WP_statue_library : GameObject[];
var WP_statue_temple : GameObject[];
var WP_statue_docks : GameObject[];
// WP : From Library
var WP_library_quarry : GameObject[];
var WP_library_workshop : GameObject[];
var WP_library_arena : GameObject[];
var WP_library_statue : GameObject[];
var WP_library_temple : GameObject[];
var WP_library_docks : GameObject[];
// WP : From Temple
var WP_temple_quarry : GameObject[];
var WP_temple_workshop : GameObject[];
var WP_temple_arena : GameObject[];
var WP_temple_library : GameObject[];
var WP_temple_statue : GameObject[];
var WP_temple_docks : GameObject[];
// WP : From Docks
var WP_docks_quarry : GameObject[];
var WP_docks_workshop : GameObject[];
var WP_docks_arena : GameObject[];
var WP_docks_statue : GameObject[];
var WP_docks_library : GameObject[];
var WP_docks_temple : GameObject[];


function Start()
{
	mode = 0; // Initial mode
	
	// Set Camera Position
	var angles = transform.eulerAngles;
	x = angles.y;
	y = angles.x;
	// Make the rigid body not change rotation
	if (rigidbody)
		rigidbody.freezeRotation = true;    
		
	// Location
	var location = "start";	// this is the default location
	var destination = "null";
}


function Update ()	// Update Game Data
{
	// Lock Camera
	if(mode == 0)
	{
	
	}
	
	// Free Look
	if(mode == 1)
	{
	
	}
	
	// Camera Orbit
	if(mode == 2)
	{
	
	}
	
	// No Clip
	if(mode == 3)
	{
	
	}
}

function OnGUI()	// Update the GUI
{
	// Camera Mode Label
	GUILayout.BeginArea(Rect(10, Screen.height - 50, 125,  Screen.height - 10), labelStyle);
	// Lock Camera
		if(mode == 0)
		{
			GUILayout.Label("Camera Mode : \n Locked Camera", labelStyle);
		}
		// Free Look
		if(mode == 1)
		{
			GUILayout.Label("Camera Mode : Free Look");
		}
		// Camera Orbit
		if(mode == 2)
		{
			GUILayout.Label("Camera Mode : Orbit");
		}
		// No Clip
		if(mode == 3)
		{
			GUILayout.Label("Camera Mode : No Clip");
		}
	
	GUILayout.EndArea();
}

function moveCamera(start, end)
{
	// Get current location
	// Get target location
/*	
	if(currentLocation == "")
	{
		// Get target location
	}*/
}

function updateZoom(zDistance)
{
/*
	zDistance = zDistance * zoomSensitivity;

    charCamera.transform.localPosition.z += zDistance;
    
    if(charCamera.transform.localPosition.z > zoomMin)
        charCamera.transform.localPosition.z = zoomMin;

    if(charCamera.transform.localPosition.z < zoomMax)
        charCamera.transform.localPosition.z = zoomMax;
 */      
}

function LateUpdate()
{
    // clamps look like this:
    rotateSens=Mathf.Clamp(rotateSens, 1, 10);
    wheelSpeed=Mathf.Clamp(wheelSpeed, 0.2, 10);

    if(Input.GetMouseButton(1))
	{   
       // Update camera position to avoid snap backs
        x += Input.GetAxis("Mouse X") * rotateSens;
        y += Input.GetAxis("Mouse Y") * rotateSens;
        var rotation = Quaternion.Euler(y, x, 0);
        transform.localRotation = rotation;
    }
/*
    if(floatCamera == true)
    {
        rotation = Quaternion.Euler(y, x, 0);
        transform.rotation = rotation;
    }
*/
    if(Input.GetAxis("Mouse ScrollWheel"))
    {
        var zDelta : float = Input.GetAxis("Mouse ScrollWheel");
        updateZoom(zDelta);
    }

     if(zoomSensitivity < zSenMin)
		zoomSensitivity = zSenMin;
     else if(zoomSensitivity > zSenMax)
	    zoomSensitivity = zSenMax;

}

On a related note. I’m using the following to try and access string variables in cameraMode.js from another script’s GUILayout button.

if(GUILayout.Button("Links", buttonStyle, GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
{
	// Get Current Location
		var cameraMode;
		cameraMode = gameObject.GetComponent(cameraMode);
		cameraMode.destination = "docks";
	//  Follow Links Spline from Current Position
	//  Set current location to Docks  load submenu(s) / Panels : Links
}

However, I keep getting this error whenever I click on the “Links” button:
ArgumentException: Type can not be null.