Search Unity

Scripts errors

Discussion in 'Editor & General Support' started by SneekySoprano, Jan 15, 2020.

  1. SneekySoprano

    SneekySoprano

    Joined:
    Jan 15, 2020
    Posts:
    4
    Hi,
    I downloaded the newest version of unity and wanted to check if the scripts works, so i made simple
    Debug.Log("Hello"); and it didnt worked i cant drag my script to any game object. It says that the class name is wrong but i checked and class name and script name was the same.
    When i want to add script in the game object it removes it automaticly.
    I was searching through the internet and i couldnt solution. Also i tried to reinstall unity with the same and older versions.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    7,201
    You have to resolve any compile errors before you can attach any of your scripts to any GameObjects. Post the entire script and we might be able to help.
     
  3. SneekySoprano

    SneekySoprano

    Joined:
    Jan 15, 2020
    Posts:
    4
    err.PNG @Joe-Censored
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class Script : MonoBehaviour
    {
    // Start is called before the first frame update
    void Start()
    {
    Debug.Log("Hello World!");

    }

    // Update is called once per frame
    void Update()
    {

    }
    }
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    7,201
    Well it looks fine. You might try closing Unity, deleting the project's library folder, and reopening the project. Then watch for any other errors which may be the actual cause if you run into this again, otherwise regenerating the library folder often resolves this kind of issue when there actually isn't an issue with the script itself.
     
  5. SneekySoprano

    SneekySoprano

    Joined:
    Jan 15, 2020
    Posts:
    4
    @Joe-Censored
    Win32Exception: ApplicationName='C:\Program Files\Unity\Editor\Data\Tools\RoslynScripts\unity_csc.bat', CommandLine='/noconfig @temp/UnityTempFile-fd06ec66d238c224e9381ed2f8abcede', CurrentDirectory='', Native error=

    this error appears after deleting library folder

    And:
    Can't add script component 'Script' because the script class cannot be found.
    I checked that the script and class name is the same
     
    Last edited: Jan 16, 2020 at 7:08 PM
unityunity