Search Unity

Roll A Ball Tutorial Build Issues

Discussion in 'Scripting' started by MoonLarva, Nov 2, 2017.

  1. MoonLarva

    MoonLarva

    Joined:
    Aug 12, 2014
    Posts:
    2
    I finished the Roll A Ball Tutorial, and everything works correctly when I play it in Unity. I get errors only when building. From researching this issue, I can only find issues with matching the name of the file or making sure "MonoBehaviour" has a "u" in it.

    Errors in console:
    One of my scripts is:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5.  
    6.  
    7. public class SphereController:MonoBehaviour {
    8.  
    9.     public float speed;
    10.     private Rigidbody rb;
    11.     private int count;
    12.     public Text countText;
    13.     public Text winText;
    14.  
    15.     void Start ()
    16.     {
    17.         rb = GetComponent<Rigidbody>();
    18.         count = 0;
    19.         SetCountText();
    20.         winText.text = "";
    21.     }
    22.  
    23.     void FixedUpdate ()
    24.     {
    25.         float moveHorizontal = Input.GetAxis ("Horizontal");
    26.         float moveVertical = Input.GetAxis ("Vertical");
    27.  
    28.         Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    29.  
    30.         rb.AddForce (movement*speed);
    31.  
    32.     }
    33.     void OnTriggerEnter(Collider other)
    34.     {
    35.         if (other.gameObject.CompareTag("Pickup"))
    36.         {
    37.             other.gameObject.SetActive (false);
    38.             count = count + 1;
    39.             SetCountText();
    40.         }
    41.  
    42.     }
    43.     void SetCountText()
    44.     {
    45.         countText.text = "Count: " + count.ToString ();
    46.         if (count >= 16) {
    47.             winText.text = "You Win!";
    48.         }
    49.     }
    50.  
    51. }
    52.  
     

    Attached Files:

  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    That's not supposed to be happening! It seems like Unity can't find Unity when it's making a build.

    What's your Unity version, and what's your build target? It might be that there's something strange in the build setup. Open the build menu, and make sure that the build target set is something you support - so Windows 64 bit if you're on a Windows 64 bit machine. If you have an older version of Unity, it was possible to not download build support for your own machine, which caused all kinds of nonsense.
     
  3. MoonLarva

    MoonLarva

    Joined:
    Aug 12, 2014
    Posts:
    2
    Thank you Baste for the quick reply!
    Unity version is 2017.2.0f3. I actually downloaded it yesterday too.
    Built as Windows 64 bit on a 64 bit machine.

    Edit: I have also just reinstalled Unity to make sure and I still get the same errors.
     
    Last edited: Nov 2, 2017
  4. Kulishnekar

    Kulishnekar

    Joined:
    Oct 17, 2017
    Posts:
    12
    Same Error Message for Roll a Ball
    Error Message:
    Assets/Scripts/CameraController.cs(5,33): error CS0246: The type or namespace name `MonoBehaviour' could not be found. Are you missing an assembly reference?

    • Version of Unity: 2017.2.0f3 Personal
    • Received message related to all scripts in Roll a Ball Tutorial
    • Received similar message when I tried to build another game, with a new script.
    • Projects are on Desktop
    • Windows operating system; new 2017 HP Omen Laptop
    • Using MonoDevelop. However, in the project folder I notice that each project I've created, has a Microsoft Visual Studio file; its file name is the same as the project (i.e. Roll A Ball).
    Thanks for your help,
    Hector
     
  5. limellama

    limellama

    Joined:
    Mar 10, 2018
    Posts:
    1
    I also have this issue. I downloaded the same version of Unity and this is what I see in MonoDevelop:
    upload_2018-4-25_8-31-6.png