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

Feedback Different Script

Discussion in '2D' started by Elric227, Jun 13, 2019.

  1. Elric227

    Elric227

    Joined:
    Jun 13, 2019
    Posts:
    2
    So im new to Unity, iv'e been watching videos to try to learn how to just learn the basics for 2d game making...
    but I keep getting stuck on the Script, On the video when they open the script they'res always goes down to a less amount of lines I dont remember exactly but around 16 and I cant follow the tutorial because mine always goes down to 18? with different stuff. Im not sure if its because a new unity update, but if anyone could help that would be great.

    (This goes down 18 lines)



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

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

    }

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

    }
    }
     
  2. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    I'm not understanding what the issue is. This is just a new default script.

    Line numbers don't really matter either. They have no effect on the logic of your script working or not.
     
  3. Elric227

    Elric227

    Joined:
    Jun 13, 2019
    Posts:
    2
    Well i was confused because on tutorials they would say go to a certain line
    For example: where it says void start they would say type in the line under that but there would be a
    Bracket there, but for them there is no bracket there?
     
    Last edited: Jun 13, 2019
  4. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    That's just a formatting option that IDE applications like Visual Studio have; placing opening curly braces on a new line or the same line:
    Code (CSharp):
    1. public class Example1 {
    2.    public void AMethod() {
    3.  
    4.    }
    5. }
    Code (CSharp):
    1. public class Example2
    2. {
    3.    public void AMethod()
    4.    {
    5.  
    6.    }
    7. }
    It's purely just a preference thing and has no effect on the script's logic. Some people like having their opening curly braces on a new line, others like having them on the same line. It doesn't matter *where or how far apart your braces are, as long as each opening brace has a closing brace and you place your code between them, your script will execute.

    In Visual Studio, you can edit your formatting preferences by going under:
    Tools > Options > Text Editor > C# > Code Style > Formatting.

    *"Where" in this context doesn't mean literally anywhere, as curly braces do have some restrictions on where they can be placed.
     
    Last edited: Jun 13, 2019