Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

My building is not working

Discussion in 'Scripting' started by Ikarishi, Nov 9, 2018 at 12:43 AM.

  1. Ikarishi

    Ikarishi

    Joined:
    Friday
    Posts:
    4
    Hi guys, i'm new on unity programming and i'm trying to build my first game, but i'm getting several errors, and mostly are these Error CS0246: The type or namespace name "MonoBehaviour" could not be found. Are you missing an assembly reference?

    All of my scripts are getting this error. this is one of my scripts to show you whats going on:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class Laser : MonoBehaviour {
    [SerializeField]
    private float _speed = 10.0f;
    public GameObject laser;
    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {
    transform.Translate(Vector3.up * _speed * Time.deltaTime);
    if(transform.position.y >= 6)
    {
    Destroy(laser);
    }

    }
    }
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    3,785
    Are you getting these errors in Unity's console? Does this happen when Unity goes to automatically compile your scripts when you switch back to Unity, or when you press the Build button on the BuildSettings window?

    https://docs.unity3d.com/Manual/BuildSettings.html
     
  3. Ikarishi

    Ikarishi

    Joined:
    Friday
    Posts:
    4
    Yes i'm getting on the console. It happens when I try to build, then nothing happens and those errors appears...
     
  4. AnneSchmidt

    AnneSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    872
    Is your script name identical to that of your class, Laser.cs?
     
  5. Ikarishi

    Ikarishi

    Joined:
    Friday
    Posts:
    4
    Yes, it's
     
  6. Ikarishi

    Ikarishi

    Joined:
    Friday
    Posts:
    4
    well, good news, i've just update my Unity and now it works fine hahah, Thank you guys anyway!
     
    Joe-Censored likes this.