Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity different script

Discussion in 'Scripting' started by Teroro, Mar 20, 2019.

  1. Teroro

    Teroro

    Joined:
    Mar 20, 2019
    Posts:
    40
    Hello.
    I was gonna create a wonderful game by the time i used to design blocks and make my character but something changed this.
    When i edited an script it shows like this:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class scr : MonoBehaviour
    {
    // Start is called before the first frame update
    void Start()
    {

    }

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

    }
    }

    but in tutorials shows like this

    public class scr : MonoBehaviour {

    any advice how to switch like in tutorials?
     
  2. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    1,035
    err...What? Are you asking how to the { which denotes the start of the class code block on to the same line as the class declaration? Have you tried the delete or backspace key?
     
  3. Teroro

    Teroro

    Joined:
    Mar 20, 2019
    Posts:
    40
    well...
    No but when i copy an script like in a video it dosen't work.
    How can i get from start of the script
    MonoBehaviour {
     
  4. WheresMommy

    WheresMommy

    Joined:
    Oct 4, 2012
    Posts:
    890
    Really? ... sorry but the { is just on the next line from what I see in your code. Actually every class is hold between those braces, get some tutorials for beginners going to be sure in understanding code basics. Dont make your life hard with coding lazy...
     
    DigitalOddity, Ryiah and Joe-Censored like this.
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    If you want the brace on the same line as the class declaration, just write it that way. It has no effect on the code.
     
    Ryiah likes this.