• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Tritonmosquito · Jan 18, 2018 at 12:06 AM · namespacetypenot found

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 !

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Buckslice · Jan 18, 2018 at 12:04 AM 1
Share

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.

avatar image Bunny83 Buckslice · Jan 18, 2018 at 01:42 AM 0
Share

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.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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 ! :)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

75 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How I can fix This? HELP ME! 0 Answers

the type or namespace cannot be found 0 Answers

Error the type or namespace name 1 Answer

transform could not be found 1 Answer

namespace UnityEditor could not be found 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges