Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 GGChua0 · Jun 24, 2017 at 08:10 AM · c#buildbuild-errorbuildingpc

Can't Build PC Standalone due to multiple namespace script errors but playable in editor

My project works fine when played in the Unity editor. However, when I try to build it for the PC, Mac, & Linux standalone, it fails to build and gives me multiple errors such as:

 Assets/Scripts/Respawn.cs(4,19): error CS0234: The type or namespace name `SceneManagement' does not exist in the namespace `UnityEngine'. Are you missing an assembly reference?  
 
 Assets/Scripts/CameraMovement.cs(5,31): error CS0246: The type or namespace name `MonoBehaviour' could not be found. Are you missing an assembly reference?  
 
 Assets/Scripts/PlayerCharacter/HERO/HeroMovement.cs(40,16): error CS0246: The type or namespace name `Vector2' could not be found. Are you missing an assembly reference?  

and ends with

 Error building Player because scripts had compiler errors


I have checked my scripts and none seem to be using the UnityEditor specific functions.
I am using Unity 5.6.1f1 Personal and there was a previous 4.6 installation when I updated to my current version (if that matters). I have also attempted a re-install of the current version by uninstalling and then re-installing the same version of Unity.

I have attached the editor log as well.

Any help would be greatly appreciated!

Editor Log

unitylog.txt (146.6 kB)
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 toddisarockstar · Jun 24, 2017 at 02:14 PM 0
Share

I might be wrong but I think this looks like the kind of error you get when the name of the script in the inspector does not match the name at the top in the actually code. did you try rena$$anonymous$$g any scripts recently?

avatar image pako · Jun 24, 2017 at 04:38 PM 0
Share

This happens to me sometimes if I add a new script in Unity and then quickly switch to Visual Studio, before Unity finishes compilation (indicated by a rotating widget at the bottom right).

Then, Visual Studio gets filled with errors all over the place, because $$anonymous$$onoBehaviours etc are not recognized/found...

A quick fix I have found is to delete the new empty script, and recreate it, letting Unity finish its compilation after each step, i.e. rotating widget at the bottom right disappears. Then everything is back to normal.

I don't know if it's the same issue as the one you're having, but it looks quite similar.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by DroidifyDevs · Jun 24, 2017 at 04:44 PM

For SceneManagement, you need to add "using UnityEngine.SceneManagement;" at the top of the script that's using SceneManagement.

Could you post CameraMovement and HeroMovement scripts?

Comment
Add comment · Show 1 · 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
avatar image GGChua0 · Jun 25, 2017 at 03:46 PM 0
Share

For the Respawn script, I already have using the using UnityEngine.Scene$$anonymous$$anagement portion as seen here:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.Scene$$anonymous$$anagement;
 
 public class Respawn : $$anonymous$$onoBehaviour {
 
     private GameObject player;
 
     private bool Instance;
 
     public static bool active = false;
 
     void Update(){
         player = GameObject.FindGameObjectWithTag("Player");
         if (player != null) {
             active = true;
         }
         if (player == null && active == true) {
             Scene activescene = Scene$$anonymous$$anager.GetActiveScene ();
             Scene$$anonymous$$anager.LoadScene (activescene.name);
         }
     }
 
 
 }

Here is the script for Camera$$anonymous$$ovement:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class Camera$$anonymous$$ovement : $$anonymous$$onoBehaviour
 {
     private GameObject player;
 
     public float smoothTimeX = 0.05f;
 
     public float smoothTimeY = 0.05f;
 
     private Vector2 velocity;
 
     private Vector2 zoompointnew;
 
     private void FixedUpdate()
     {
         this.player = GameObject.FindGameObjectWithTag("Player");
         if (!Input.Get$$anonymous$$ey($$anonymous$$eyCode.$$anonymous$$ouse1) && this.player != null)
         {
             Camera.main.orthographicSize = 15f;
             float x = $$anonymous$$athf.SmoothDamp(base.transform.position.x, this.player.transform.position.x, ref this.velocity.x, this.smoothTimeX);
             float num = $$anonymous$$athf.SmoothDamp(base.transform.position.y, this.player.transform.position.y, ref this.velocity.y, this.smoothTimeY);
             base.transform.position = new Vector3(x, num + 0.5f, base.transform.position.z);
         }
         if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.$$anonymous$$ouse1) && this.player != null)
         {
             Camera.main.orthographicSize = 5f;
             this.zoompointnew.x = Camera.main.ScreenToWorldPoint(Input.mousePosition).x;
             this.zoompointnew.y = Camera.main.ScreenToWorldPoint(Input.mousePosition).y;
             float x2 = $$anonymous$$athf.SmoothDamp(base.transform.position.x, this.zoompointnew.x, ref this.velocity.x, 2f * this.smoothTimeX);
             float y = $$anonymous$$athf.SmoothDamp(base.transform.position.y, this.zoompointnew.y, ref this.velocity.y, 2f * this.smoothTimeY);
             base.transform.position = new Vector3(x2, y, base.transform.position.z);
         }
     }
 }


I have this nagging feeling that these problems are not with the scripts themselves but may be an error with my installation of Unity itself. Thank you for the reply!

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.

Follow this Question

Answers Answers and Comments

68 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

Related Questions

Distribute terrain in zones 3 Answers

Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers

How do you destroy a GameObject during the build process? 1 Answer

Multiple Cars not working 1 Answer

Build error when using BooleanOps.dll 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges