Please help me with code to gift for Little Sister

I am new to coding and I am getting this message:

Assets\Scripts\CameraManger.cs(50,5) error cs1022: type or namespace definiton, or end-of-file expected.

This is the code any help would be great I am trying to make a fnaf like game for little sister and this is step 1.

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

public class Cameramanger : MonoBehaviour; 

    
    public Camera Camera_SercuirtyRoom;
    public Camera cam_1;
    public Camera cam_2;
    public Camera cam_3;
    public Camera cam_4;
    public Camera cam_5;
    public Camera cam_6;
    public Camera cam_7;
    public Camera cam_8;
    public Camera cam_9;
    public Camera cam_10; 
    public Camera cam_11;
    public Camera cam_12;

    protected Camera[] cameras;

    protected int currentCamera;

    void awake()
    {
        cameras = new Camera[13];

        cameras [0] = Camera_SercuirtyRoom;
        cameras [1] = cam_1;
        cameras [2] = cam_2;
        cameras [3] = cam_3;
        cameras [4] = cam_4;
        cameras [5] = cam_5;
        cameras [6] = cam_6;
        cameras [7] = cam_7;
        cameras [8] = cam_8;
        cameras [9] = cam_9;
        cameras [10] = cam_10;
        cameras [11] = cam_11;
        cameras [12] = cam_12 ;
    }
    
    // Start is called before the first frame update
    void Start() {


    }
    }




void IncCamera()
{
   cameras[currentCamera].enable = false;


   currentCamera++;

  if (currentCamera >= cameras.Length)
  {
    currentCamera = 0;
  }

  cameras[currentCamera].enable = true;


}

void decCamera() 
{
  cameras[currentCamera].enable = false;
  
  currentCamera--;

  if (currentCamera < 0)
  {
    currentCamera = cameras.Length-1;
  }
  cameras[currentCamera].enable = true;
}

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

      if (Input.GetKeyup  (KeyCode.UpArrow)) 
      {
        IncCamera();
      }

      if (Input.GetKeyup  (KeyCode.DownArrow)) 
      {
        decCamera();
      }


    }

3 Answers

3

You have two closing curly braces here for the Start() function. Delete one of them.

Remember that the numbers after the filename in the error message will usually tell you where the error is (in this case row 50, column 5).

Also public class Cameramanger : MonoBehaviour; should be public class Cameramanger : MonoBehaviour {.

ty for the help the last error I have is for (56, 1) tho this is the code for it and I don’t see whats wrong

void IncCamera()
{
    cameras[currentCamera].enable = false;
    currentCamera++;
    if (currentCamera >= cameras.Length)
    {
        currentCamera = 0;
    }
    cameras[currentCamera].enable = true;
}

What is the error message now?

it says 56, 1: that is 56 and down Assets\Scripts\CameraManger.cs(56,1): error CS8803. top level statemnts must precede namespace and type declarations

(Adding a new reply to address the remaining issue)
Your class definition is incorrect:

public class Cameramanger : MonoBehaviour; 

You should not have a semi-colon at the end and it needs open and closed curly braces to contain everything in the class.

public class Cameramanger : MonoBehaviour
{
   //all the functions and stuff 
}

Also, function names are case sensitive, so you need to capitalize the A here if you want Unity to run this function when the object is activated. Awake()

void awake()

Okay ty and doing that made A cS8803 error in 28,5 and a CS1022 in 52,1

I don't know all of these codes off the top of my head and I also don't know what the line numbers are as you make changes to your code. It may help to google the error messages. If you can't figure out the issues from a google search, then please post the updated code.

Okay i've goggled it and have fixed more of the code tho I am still having trouble with 28, 5 CS8803 below is all on line 28 ~~~ void Awake() { ~~~

Is your definition for Awake() contained inside the curly braces of the class definition?