- Home /
Types and namespace not found...
Ok, so I'm new to Unity and C# but I wrote a tiny script which runs without a problem inside Unity. But when I try to export it (build) I get a bunch of errors all telling me types are not found, and it's pretty much all the types I used... So it doesn't find MonoBehaviour, Vector3 or Transform.
The script looks like this :
using System.Collections.Generic; using UnityEngine; public class CameraBehaviour : MonoBehaviour { Vector3 myVectorZ; Vector3 myVectorY; Vector3 myVectorX; Transform myTransform; void Awake () {
myTransform = GetComponent<Transform> (); myVectorZ = new Vector3 (myTransform.position.x, myTransform.position.y, myTransform.position.z+2); myVectorY = new Vector3 (myTransform.position.x, myTransform.position.y+2, myTransform.position.z); myVectorX = new Vector3 (myTransform.position.x+2, myTransform.position.y, myTransform.position.z); } // Use this for initialization void Start () { } // Update is called once per frame void FixedUpdate () { if ( Input.GetKey( "space" ) ) { transform.Translate( myVectorZ , Space.Self); Debug.Log ("Fixed :"); Debug.Log (myTransform.position.z); } } void Update () { if ( Input.GetKey( "space" ) ) { transform.Translate( myVectorZ , Space.Self); Debug.Log ("NotFixed :"); Debug.Log (myTransform.position.z); } }
} *
I'm guessing I didn't think of a simple thing that ruin everything but I didn't find an answer fitting my problem. Sorry if I'm not clear, not english... Thanks in advance for your answers !
I imported your code into Unity and it works fine. $$anonymous$$ake sure you are building within Unity and not through Visual Studio or something else.
Right, also it would be interesting what target platform you're building for and when you actually get errors, please copy them from the console and include them in the question.
Answer by Tritonmosquito · Jan 18, 2018 at 08:23 AM
Actually I managed to finally fix it !
I was having errors when trying to export for windows only, I succeeded to build for Html5, but when I tried the windows thing I kept getting errors like "The type or namespace name XXX could not be found (are you missing using directive or an assembly reference?)" for every type I put in the code.
The problem came from the Facebook exporting module for some reason, I got rid of it directly in the Plugin folder and now I can build for Windows.
Absolutely no idea why it's connected though :/
Thanks for your answers and if you have a way to reinstall the facebook module without getting this error again ! :)
Your answer
Follow this Question
Related Questions
How I can fix This? HELP ME! 0 Answers
The type or namespace 'blabla' could not be found 1 Answer
StartCoroutine namespace or type not found 2 Answers
Name GUI input help in C# 0 Answers