I’m creating a minimap system that toggles to use the entire screen or just a small portion.
My code is contained in MinimapCamera.js which is assigned to a GameObject of the same name. Now I need to access this information from other scripts, namely my movement and AI ones.
Some code:
in MinimapCamera.js:
static var mapOpen : boolean = false;
...
function Update () {
if(Input.GetButtonDown("MinimapToggle")) {
toggleMinimap();
}
...
function toggleMinimap() {
if(mapOpen) {
camera.rect = Rect (0,0,1,1);
mapOpen = true;
Screen.lockCursor = true;
}
else {
camera.rect = Rect (0.8,0.8,1,1);
mapOpen = false;
Screen.lockCursor = false;
}
}
Then, in the standard FPS walker script:
function Update() {
if (grounded !MinimapCamera.mapOpen) {
...
It looks like the JS script it not available at the FPS script.
This usually happens if you’re trying to access your JS script form a C# script (which I guess is not your case), or if one of the scripts is into a folder that compiles before the other.
For instance, create a “Plugins” folder and put your script camera there and give it another try.
Is it really good to know what is compiled first ? Everything will be done when doing Ctrl + S…? And if anything error comes, it will be shown in the console.
And what if there are references of C# files, in Javascript files ? The inverse also, in many scripts ? A giant mess to remember what to compile first ?
Slightly off the new discussion but I’ve been through and hopefully explained what I’m doing.
Random test build here, but I’m not quite used to web player configuration just yet so there are a few errors. M for minimap toggling, WASD + mouselook for standard view, and then point/click (thanks to the amazing A* pathfinding system!) navigation in the map view. The mouse scroll wheel zooms in and out on the map.