Errors in FPS tutorial

Dear Sirs:

I have two question about how to fix these two main errors in below tutorial. http://unity3d.com/support/resources/files/FPS_Tutorial_Completed.zip

  1. In file LevelLoadFade.js Error: Assets/Misc Scripts/LevelLoadFade.js(21,42): BCE0019: 'DoFade' is not a member of 'UnityEngine.Component' --> The error line code is 'fade.GetComponent(LevelLoadFade).DoFade(level, fadeLength, false);'

  2. In file LevelLoadFade.js Error: Assets/Misc Scripts/LevelLoadFade.js(60,30): BCE0004: Ambiguous reference 'LoadLevel': UnityEngine.Application.LoadLevel(String), UnityEngine.Application.LoadLevel(int). --> The error line code is 'Application.LoadLevel(level);'

Thanks for your precious help.

I am pretty sure the issue here is that this project isn't designed for Unity iPhone (although it can still open the file). A lot of the dynamic typing features of JS can't be used with the iPhone, since Apple doesn't allow just-in-time compilation on the device.

use (fade.GetComponent(LevelLoadFade) as LevelLoadFade).DoFade(level, fadeLength, false);

cheers

OMG. Thanks for your answer. I'm trying change a variable in other script in a game for iPhone, and no good results, BUT NOW I CAN DO IT !

I use the simple line for change a variable in other script.

(camera.main.GetComponent("nameofscript") as nameofscript).variableofscript = value;

THKS JAN HELLEMAN!

Hello! Did anyone make the LevelLoadFade.js work on iphone? What do you have to change in the script to make it work? Did use Jan Helleman change but it didnt work!

use (fade.GetComponent(LevelLoadFade) as LevelLoadFade).DoFade(level, fadeLength, false);

I didnt understand Bernardos script change?

Hope anyone can help on this Thanks!!

here is the code `/* Usage:

// Load my level    
LevelLoadFade.FadeAndLoadLevel("mylevel", Color.white, 0.5);

// Reset the current level
LevelLoadFade.FadeAndLoadLevel(Application.loadedLevel, Color.white, 0.5);

*/

static function FadeAndLoadLevel (level, fadeTexture : Texture2D, fadeLength : float) { if (fadeTexture == null) FadeAndLoadLevel(level, Color.white, fadeLength);

var fade = new GameObject ("Fade");
fade.AddComponent(LevelLoadFade);
fade.AddComponent(GUITexture);
fade.transform.position = Vector3 (0.5, 0.5, 1000);
fade.guiTexture.texture = fadeTexture;
fade.GetComponent(LevelLoadFade).DoFade(level, fadeLength, false);

}

static function FadeAndLoadLevel (level, color : Color, fadeLength : float) { var fadeTexture = new Texture2D (1, 1); fadeTexture.SetPixel(0, 0, color); fadeTexture.Apply();

var fade = new GameObject ("Fade");
fade.AddComponent(LevelLoadFade);
fade.AddComponent(GUITexture);
fade.transform.position = Vector3 (0.5, 0.5, 1000);
fade.guiTexture.texture = fadeTexture;

DontDestroyOnLoad(fadeTexture);
fade.GetComponent(LevelLoadFade).DoFade(level, fadeLength, true);

}

function DoFade (level, fadeLength : float, destroyTexture : boolean) { // Dont destroy the fade game object during level load DontDestroyOnLoad(gameObject);

// Fadeout to start with
guiTexture.color.a = 0;

// Fade texture in
var time = 0.0;
while (time < fadeLength)
{
    time += Time.deltaTime;
    guiTexture.color.a = Mathf.InverseLerp(0.0, fadeLength, time);
    yield;
}
guiTexture.color.a = 1;
yield;

// Complete the fade out (Load a level or reset player position)
Application.LoadLevel(level);

// Fade texture out
time = 0.0;
while (time < fadeLength)
{
    time += Time.deltaTime;
    guiTexture.color.a = Mathf.InverseLerp(fadeLength, 0.0, time);
    yield;
}
guiTexture.color.a = 0;
yield;

Destroy (gameObject);

// If we created the texture from code we used DontDestroyOnLoad,
// which means we have to clean it up manually to avoid leaks
if (destroyTexture)
    Destroy (guiTexture.texture);

}`