Error cs1529 unity

(1)Assetsep 7BRS_ChangeCircle.cs(1,25): error CS1002: ; expected (2)Assetsep 7BRS_ChangeCircle.cs(6,2): error CS1513: } expected (3)Assetsep 7BRS_ChangeCircle.cs(7,1): error CS1529: A using c...

When you have a number of errors in the same sourcecode file, then it’s usually a good idea to fix them from top to bottom, because fixing one error might remove or change the errors below it. So I copied your code to a new file in Visual Studio and went through the errors from top to bottom.


The first error is very straight forward: A semicolon is expected on line 1, position 25. So just add a semicolon after the very first line:

using System.Collections;

Funny thing: Visual Studio now displays that line in gray, which tells us that there isn’t actually anything in this file which requires this using-declaration. So we could actually just as well remove it altogether.


Then you are apparently trying to create two MonoBehaviours in one sourcecode file: BRS_ChangeCircle and Score. This won’t work. The C# language does allow you to have multiple classes in one sourcecode file, but Unity requires a separate file for each MonoBehaviour in order to allow you to assign them to GameObject’s. And even if you would want to create a class inlined in another (which you might want to do from time to time, just not with a MonoBehaviour), then the using-declarations required by the inner class need to be on top of the whole file. So remove this part and put it into a new file Score.cs:

using UnityEngine;
using System.Collections;
 
public class Score : MonoBehaviour {

    int score = 0;

    void OnGUI() {
        guiText.text = "Score: " + score;
    }

}

There is also another problem with this piece of code, and that that there is no variable guiText in that script. It is likely supposed to be a public UnityEngine.UI.Text or public TMPro.TextMeshPro.


Next error is this line:

public List<int> ZoneTimes;

This one is simple, and Visual Studio already provides an auto-correction. You forgot to add using System.Collections.Generic; to the very top of the script. This package is required for the class List.


Then there are just two errors remaining, which are related to the class WorldCircle being unknown. This is not a Unity or C# standard class, so I assume it’s another class from your project. So if you have that class in your project, you shouldn’t get that error.


Conclusion: It looks as if you copied a very long script written by someone else to your project, and then you tried to modify it by adding code you saw in some YouTube tutorial without really understanding what you were doing.

It’s hard to get anywhere in Unity when you don’t have at least a basic understanding of the C# language and how to interpret its error messages. If my impression is correct, then I would really recommend to do a basic, technology-neutral C# tutorial first.

Permalink

Cannot retrieve contributors at this time

description title ms.date f1_keywords helpviewer_keywords ms.assetid

Compiler Error CS1529

Compiler Error CS1529

07/20/2015

CS1529

CS1529

672a6fd1-3a1f-422c-a29f-46f196d15211

Compiler Error CS1529

A using clause must precede all other elements defined in the namespace except extern alias declarations

A using clause must appear first in a namespace.

Example

The following sample generates CS1529:

// CS1529.cs  
namespace X  
{  
    namespace Subspace  
    {  
        using Microsoft;  
  
        class SomeClass  
        {  
        };  
  
        using Microsoft;      // CS1529, place before class definition  
    }  
  
    using System.Reflection;  // CS1529, place before namespace 'Subspace'  
}  
  
using System;                 // CS1529, place at the beginning of the file  

So basically, my distant friend is making a game, and I decided to help him. I created Unity project, placed the assets, scenes and classes, all this stuff. When it came to SceneChanger.cs (not mine, my friend’s class), it’s always throwing an error, no matter was it him fixing an error or me. Here’s a code and errors:

SceneChanger.cs:

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

public class SceneChanger : MonoBehaviour {

private float timer = 2.0f; 

void OnTriggerEnter(Collider other) 
{
      timer -= Time.deltaTime; 
      if (timer <=0)
{
    static void ChangeScene(string LoadingGame)
    {
        SceneManager.LoadScene (MainMenu);
    }
    static void Exit()
    {
        Application.Quit ();
    }
}

And here are the errors:

AssetsScenesSceneChanger (5).cs(23,2): error CS1513: } expected

AssetsScriptsAssetExitVoid.cs(6,2): error CS1513: } expected

AssetsScriptsEnemyAI.cs(23,1): error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

AssetsScriptsEnemyAI.cs(24,1): error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

AssetsScriptsEnemyAI.cs(21,1): error CS1028: Unexpected preprocessor directive

AssetsScriptsEnemyAI.cs(22,1): error CS1022: Type or namespace definition, or end-of-file expected

AssetsScriptsObjPoolShot.cs(58,52): error CS1026: ) expected

AssetsScriptsObjPoolShot.cs(58,57): error CS1002: ; expected

AssetsScriptsObjPoolShot.cs(58,57): error CS1513: } expected

AssetsScriptsPlayerMoveActive.cs(2,1): error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

AssetsScriptsSceneChanger.cs(6,42): error CS1514: { expected

AssetsScriptsSceneChanger.cs(6,42): error CS1513: } expected

AssetsScriptsSceneChanger.cs(14,8): error CS1513: } expected

AssetsScriptsSceneChanger.cs(26,1): error CS1022: Type or namespace definition, or end-of-file expected

AssetsScriptsSceneChanger.cs(30,1): error CS1022: Type or namespace definition, or end-of-file expected

AssetsScriptsSceneChanger.cs(32,8): error CS1002: ; expected

AssetsScriptsSceneChanger.cs(34,1): error CS0116: A namespace cannot directly contain members such as fields or methods

AssetsScriptsSceneChanger.cs(34,10): error CS1022: Type or namespace definition, or end-of-file expected

AssetsScriptsSceneChanger.cs(35,1): error CS0116: A namespace cannot directly contain members such as fields or methods

AssetsScriptsSceneChanger.cs(35,16): error CS1022: Type or namespace definition, or end-of-file expected

AssetsScriptsSceneChanger.cs(35,21): error CS0116: A namespace cannot directly contain members such as fields or methods

AssetsScriptsSceneChanger.cs(35,25): error CS1022: Type or namespace definition, or end-of-file expected

Thanks you beforehand!

I keep getting this error CS1529: A using clause must precede
all other elements defined in the namespace except extern alias
declarations. On the line of code (using System;) I
highlighted in bold to tell the difference.

this is a c# programming course I just started. I appreciate the
help.

using System;

using align;

class Grades {

public static void Main(string[] args) {

const float MIDTERM_PERCENTAGE = .25F;

const float FINALEXAM_PERCENTAGE = .25F;

const float RESEARCH_PERCENTAGE = .30F;

const float PRESENTATION_PERCENTAGE = .20F;

int midterm = 70;

int finalExamGrade = 80;

int research = 90;

int presentation = 100;

float finalNumericGrade = 0;

finalNumericGrade =

(midterm * MIDTERM_PERCENTAGE) +

(finalExamGrade * FINALEXAM_PERCENTAGE) +

(research * RESEARCH_PERCENTAGE) +

(presentation * PRESENTATION_PERCENTAGE);

align.xyz abc = new align.xyz();

abc.disp(«Midterm grade is : » + midterm);

abc.disp(«Final Exam grade is : » + finalExamGrade);

abc.disp(«Research grade is : » + research);

abc.disp(«Presentation grade is: » + presentation);

abc.disp(«nThe final grade is: » + finalNumericGrade);

}

}

using System;

namespace align

{

class xyz

{

public void disp(string str)

{

Console.WriteLine(str);

}

}

}

I’m trying to integrate Wwise into a Unity 2017.1.0f1 project, but it consistantly fails and brings up the following script compiling errors:

  1. A script compilation error occurred during the execution in Unity. Please click Open Log to review the Unity log.

  2. Assets/Wwise/Editor/WwiseMenu/Common/AkExampleAppBuilderBase.cs(109,45): error CS0619: `UnityEditor.BuildTarget.iPhone’ is obsolete: `Use iOS instead (UnityUpgradable) -> iOS’

  3. Assets/Wwise/Editor/WwiseMenu/Common/AkExampleAppBuilderBase.cs(142,45): error CS0619: `UnityEditor.BuildTarget.iPhone’ is obsolete: `Use iOS instead (UnityUpgradable) -> iOS’

  4. Assets/Wwise/Editor/WwiseSetupWizard/AkWwisePostImportCallbackSetup.cs(217,57): error CS1061: Type `AkWwiseProjectData’ does not contain a definition for `CurrentPluginConfig’ and no extension method `CurrentPluginConfig’ of type `AkWwiseProjectData’ could be found. Are you missing an assembly reference?

  5. Assets/Wwise/Editor/WwiseSetupWizard/AkWwisePostImportCallbackSetup.cs(219,33): error CS1061: Type `AkWwiseProjectData’ does not contain a definition for `CurrentPluginConfig’ and no extension method `CurrentPluginConfig’ of type `AkWwiseProjectData’ could be found. Are you missing an assembly reference?

  6. The project was not modified.

Integration worked fine with Unity 5, and it’s necessary for the current project to use 2017 so there’s no choice of going back. 

Any help to fix this issue?

Понравилась статья? Поделить с друзьями:
  • Error cs1525 unexpected symbol end of file
  • Error cs1525 invalid expression term unity
  • Error cs1525 invalid expression term string
  • Error cs1525 invalid expression term int
  • Error cs1520 method must have a return type unity