So I’m going through converting my scripts to use #pragma strict – so far it’s been pretty smooth, but I’ve run into a very odd error.
The error only happens when #pragma strict is in this virtual button handler script:
#pragma strict
//virtual buttons talk to this script. this script talks with bike/wheels to perform actions
var activeBike : rubberBike;
var activeWheel1 : rubberWheel;
var activeWheel2 : rubberWheel;
//wheels
function virtualAccel(){
activeWheel1.virtualAccel();
activeWheel2.virtualAccel();
}
function virtualBrake(){
activeWheel1.virtualBrake();
activeWheel2.virtualBrake();
}
//bike
function virtualNudgeL(){
activeBike.continuousNudge(1);
}
function virtualNudgeR(){
activeBike.continuousNudge(0);
}
function virtualFlip(){
activeBike.flip();
}
But the error:
InvalidProgramException: Invalid IL code in Menu:Start (): IL_013e: add
points to an entirely different script that I’ve already successfully added pragma strict to.
here’s the Menu script’s Start() –
function Start(){
if(globalManager.hasPlayed){
//go to level select menu if we're coming from a played level (will have to change this when we give clients level editor)
panelMgr = GameObject.Find("menuCam").GetComponent(UIPanelManager);
panelMgr.BringIn("levelSelectPanel");
}
//set camera option button correctly
cameraToggleButton = GameObject.Find("cameraButton").GetComponent(UIStateToggleBtn);
if(!PlayerPrefs.HasKey("orthoCamera")){
PlayerPrefs.SetInt("orthoCamera", 0);
}
if(PlayerPrefs.GetInt("orthoCamera") == 1){
cameraToggleButton.SetToggleState("camOrtho");
}
else{
cameraToggleButton.SetToggleState("camPersp");
}
//get files
// for resources folder - levelFiles = System.IO.Directory.GetFiles("Assets/Resources/Levels/");
levelFiles = System.IO.Directory.GetFiles(Application.dataPath+"/Levels/");
//remove paths
for (var i = 0; i < levelFiles.length; i++){
levelFiles[i] = System.IO.Path.GetFileNameWithoutExtension(levelFiles[i]);
levelsList += levelFiles[i]+"\n";
}
status = Application.dataPath+"/Levels/";
DontDestroyOnLoad(this);
}
But like I said, it only happens when #pragma strict is in the OTHER script (I can remove it and everything works fine again). Why is that happening and what can I do to fix it?! Is there actually any invalid code in the Menu script?
edit: Also noticing Menu.js looks weird in the inspector – like it’s not registering returns. What’s going on?