Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

My building is not working

Discussion in 'Scripting' started by Ikarishi, Nov 9, 2018.

  1. Ikarishi

    Ikarishi

    Joined:
    Nov 9, 2018
    Posts:
    5
    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:
    4,925
    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:
    Nov 9, 2018
    Posts:
    5
    Yes i'm getting on the console. It happens when I try to build, then nothing happens and those errors appears...
     
  4. APSchmidt

    APSchmidt

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

    Ikarishi

    Joined:
    Nov 9, 2018
    Posts:
    5
    Yes, it's
     
  6. Ikarishi

    Ikarishi

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