Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Super Beginner Error Question - Identifier Expected

Discussion in 'Scripting' started by thomasforman, Apr 28, 2020.

  1. thomasforman

    thomasforman

    Joined:
    Apr 27, 2020
    Posts:
    5
    Hello, I started using Unity yesterday and I am already having so much trouble! I created a scene in Maya that I threw into Unity. I downloaded standard assets because I wanted to create a first-person camera within my scene. When I try to run my project, I originally had an error that said something like "don't use GUItext, use UItext" so I changed that, and then it said something like "identify if static or active". Now it's saying I have a "CS1001 error: Identifier expected" in my simpleactiviatormenu code. The error is in line 3 and 14. Can anyone help me? Also if anyone has some tutorials so I could learn to fix errors alone in the future that would be awesome. Here is my code.

    using System;
    using UnityEngine;
    using UIText;
    using static;



    #pragma warning disable 618
    namespace UnityStandardAssets.Utility
    {
    public class SimpleActivatorMenu : MonoBehaviour
    {
    // An incredibly simple menu which, when given references
    // to gameobjects in the scene
    public UIText camSwitchButton;
    public GameObject[] objects;


    private int m_CurrentActiveObject;


    private void OnEnable()
    {
    // active object starts from first in array
    m_CurrentActiveObject = 0;
    camSwitchButton.text = objects[m_CurrentActiveObject].name;
    }


    public void NextCamera()
    {
    int nextactiveobject = m_CurrentActiveObject + 1 >= objects.Length ? 0 : m_CurrentActiveObject + 1;

    for (int i = 0; i < objects.Length; i++)
    {
    objects.SetActive(i == nextactiveobject);
    }

    m_CurrentActiveObject = nextactiveobject;
    camSwitchButton.text = objects[m_CurrentActiveObject].name;
    }
    }
    }
    Thanks
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,971
    Welcome! Please check out the first post in the forum for making your code readable and formatted.

    Also, when you do please correlate the actual line number you see in the error message with the line number in your code above, as the line numbers may differ slightly once posted.
     
  3. matkoniecz

    matkoniecz

    Joined:
    Feb 23, 2020
    Posts:
    170
    Kurt-Dekker likes this.
  4. thomasforman

    thomasforman

    Joined:
    Apr 27, 2020
    Posts:
    5
    Yeah, you are so right. I only have been approaching it so blindly for the past two days as my 3D modeling teacher has made us approach like this. Once the course is over, I plan to actually start learning how to do Unity the right way. I was able to find the solution to my problem by the way. Cheers.
     
  5. matkoniecz

    matkoniecz

    Joined:
    Feb 23, 2020
    Posts:
    170
  6. thomasforman

    thomasforman

    Joined:
    Apr 27, 2020
    Posts:
    5