Search Unity

Unity "No MonoBehaviour script" Run impossible

Discussion in '2D' started by MalekRBAM, Dec 3, 2019.

  1. MalekRBAM

    MalekRBAM

    Joined:
    Dec 3, 2019
    Posts:
    3
    Hi!

    I start on Unity, and I'm on my first 2D game project. I created a platform, a character, a background, I put the "box colider" on the platform and the character to which I also added gravity, so when I compile the character falls on the platform "OK" ! So I create a custom script for him to advance, (at the beginning I could not open the script to edit it because I did not have MonoDev or MVS (this one did not want s' install) so I use NotePad ++ I integrated it to Unity and I was able to open the script on Notepad ++
    Here is the script:

    Code (CSharp):
    1. using System.Collections;
    2.  
    3. using System.Collections.Generic;
    4.  
    5. using UnityEngine;
    6.  
    7. public class CharacBehaviour : MonoBehaviour
    8.  
    9. {
    10.  
    11. public Rigidbody2D rb;
    12.  
    13. public float vitesse;
    14.  
    15.     // Start is called before the first frame update
    16.  
    17.     void Start()
    18.  
    19.     {
    20.  
    21. rb.velocity += new Vecteur2(vitesse,0);
    22.  
    23.     }
    24.  
    25.     // Update is called once per frame
    26.  
    27.     void Update()
    28.  
    29.     {
    30.  
    31.     }
    32.  
    33. }
    _________

    I save, and I try to run the game but there "All compiler error .." and in my console I have an error with the red panel but without reason there is nothing written, I check the script there has no error in it, but in "Inspector" there is on the "CharacBehaviour import setting" a message below that says "No MonoBehaviour script in this file, or their .."

    Where am I planted? How to solve this problem?

    Thank you in advance.
     
    Last edited: Dec 5, 2019
  2. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    776
  3. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    1,489
    @MalekRBAM

    MonoDevelop is no longer supported for current Unity versions - Why not try Visual Studio code?

    Or try installing Visual Studio 2019 Community Edition IDE (it can be installed directly from Unity hub when installing some version of Unity).

    Notepad++ is a nice generic text editor, but not very easy to use with Unity if you want full integration with Unity Editor.
     
    MisterSkitz likes this.
  4. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    1,489
    @MalekRBAM

    And use codetags when posting.

    Please edit your post, here is the info how you can do this:
    https://forum.unity.com/threads/using-code-tags-properly.143875/

    When code is formatted It is quite obvious to see where the problem is:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class CharacBehaviour : MonoBehaviour
    6. {
    7.     public Rigidbody2D rb;
    8.     public float vitesse;
    9.  
    10.     void Start()
    11.     {
    12.         rb.velocity += new Vecteur2(vitesse,0);
    13.     }
    14.  
    15.     void Update()
    16.     {
    17.     }
    18. }
    There is no such thing as using some non-english language words for C# language keywords:

    rb.velocity += new Vecteur2(vitesse,0);


    You have to use correct C# keywords.
     
    Last edited: Dec 4, 2019
    MisterSkitz likes this.
  5. MalekRBAM

    MalekRBAM

    Joined:
    Dec 3, 2019
    Posts:
    3
    I watch a french tutorial nd he use it like that, so need i to write "vector" nd "(speed,0)"
    i switched up to Xamarin Studio, i created a new project, i'v donwload a character with his script, and..
    upload_2019-12-5_14-30-26.png
    Always the error in console nd now "the associated script can not be loaded.." however it in the character prefabs,i guess'nt there is a error in script again
     

    Attached Files:

  6. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    1,489
    @MalekRBAM

    "I watch a french tutorial nd he use it like that,"

    The reason for error you get is the one I explained.

    AFAIK there is no way you could do something like use some other language... you must have misunderstood something in the video you watched.

    "i switched up to Xamarin Studio,"

    Why the resistance to recommended tools? I think you are not going to get anything from using Xamarin Studio, especially when you are first time Unity user.

    I think you should head over to Unity learn section, and watch some tutorials first, then learn more about C# basic syntax so you can see what you should expect from the C# language.
     
    Last edited: Dec 5, 2019
    MisterSkitz likes this.
  7. MalekRBAM

    MalekRBAM

    Joined:
    Dec 3, 2019
    Posts:
    3
    Sans titresds.png
    And sudently it close.. that why i can't use Visual Studio,because i can't install it,nd i don't know why.. i repeat this many times,i've re-downloaded from many sources same thing.. i donwload it from web that don't work,i try with unityHub same thing, look:
    Sans titresdsd.png
    the donwloading start but a few moment later..
    Sans sdsdtitre.png
    Nothing.. where is it? that's stopped or i don't know, nd without any message error or something else.
    You understood now why i can't use Visual Studio?
    what can i do now? tell me buddie
     
  8. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    776
    Where are you trying to download the file from? Are you clicking on a link provided by the tutorial, or are you using the Legit Unity site? (UnityHub)

    If you're clicking on a link, it could be a mirrored site and malicious. Could just be obsolete with your current version of Unity and won't download?

    Here I found this link that may be of some help:

    https://forum.unity.com/threads/unity-hub-doesnt-include-visual-studio-component.536636/