I have an error when I’m trying to build my project but i have a problem.
The error is : "A local variable ‘movie’ cannot be used before it is declared.
I don’t understand why because when i’m running the project it’s working properly.
Thanks for the help !
Her is my script :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class radarPlace : MonoBehaviour {
public Camera camera;
public GameObject radar;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void musicEnter()
{
camera.transform.position = new Vector3(4.851f, 1f, -2.868f);
Renderer r = radar.GetComponent();
MovieTexture movie = (MovieTexture)r.material.mainTexture;
movie.Play();
}
}
Make sure and use Code Tags when pasting code into the forums.
This error happens when you attempt to build? So you know, MovieTexture is not supported on Android or iOS, there is an alternative method for mobile:
Otherwise, I don’t know why you would be getting those errors. Are your files saved? (i have left unsaved files many times wondering why something didn’t work.)