Hi, I have been using NGUI for awhile now but I recently ran into an issue.
I was creating an Javascript to pair with NGUI interface. It works alright for the first run, but as soon as I save my workspace and relaunch Unity, NGUI fails with every NGUI associated script saying "The associated script can not be loaded. Please fix any compile errors and assign a valid script". All NGUI assets are removed from the scene as well.
But as soon as I remove the offending script from my folder, the entire thing goes back to normal.
//NGU items
//var buildPanelOpen : boolean = false;
//var buildPanelTweener : TweenPosition;
//Placement Plane Items
var placementPlanesRoot : Transform; // attach the placement plane root
var hoverMat : Material; // attach the hover material to this slot
var placementLayerMask : LayerMask; // calls up the layer mask selection
private var originalMat : Material;
private var lastHitObj : GameObject;
//Build Selection Items
var onColor : Color;
var offColor : Color;
var allStructures : GameObject[];
var buildBtnGraphics : UISlicedSprite[];
private var structureIndex : int = 0;
function Start ()
{
//reset the structure index, refresh the GUI
//structureIndex = 0;
UpdateGUI();
}
function Update ()
{
var ray = Camera.main.ScreenPointToRay ( Input.mousePosition );
var hit : RaycastHit;
if ( Physics.Raycast ( ray, hit, 1000, placementLayerMask ) )
{
if ( lastHitObj )
{
lastHitObj.renderer.material = originalMat;
}
lastHitObj = hit.collider.gameObject;
originalMat = lastHitObj.renderer.material;
lastHitObj.renderer.material = hoverMat; // sets the planes material to the highlighted material
}
else // if the raycast didn’t hit anything
{
if ( lastHitObj ) // if we had previously hit something
{
lastHitObj.renderer.material = originalMat; // visually de select that object
lastHitObj = null; // nullify the plane selection
}
}
}
function UpdateGUI ()
{
//Go through all structure buttons (buttons in the build panel). and set them to “off”
for ( var theBtnGraphic : UISlicedSprite in buildBtnGraphics )
{
theBtnGraphic.color = offColor;
}
//set the selected build button to “on”
buildBtnGraphics [ structureIndex ].color = onColor;
}
I've inserted the code that the script contains.
Any help will be greatly appreciated!