Hi everyone i’m new to Unity scripting and i cant deal with the problem please someone help me
here is the code:
using UnityEngine;
using System.Collections;
public class testScript : MonoBehaviour
{
int i = 1;
// Use this for initialization
void Start()
{
for (i = 1; i > 6; i++)
{
Debug.Log("value of i = " + i);
}
Debug.Log("i'm out of the loop");
} //the problem is cs1513 c# expected unity here(21.line)
// Update is called once per frame
void Update()
{
}
program i’m using Microsoft Visual Studio
Thanks in advance!!!
Programmer
122k22 gold badges237 silver badges329 bronze badges
asked Aug 10, 2016 at 5:30
You only missing }
at the end of the script. The last }
should close the class {
. This was likely deleted by you by mistake. Sometimes, Unity does not recognize script change. If this problem is still there after making this modification, simply close and re-open Unity and Visual Studio/MonoDevelop.
using UnityEngine;
using System.Collections;
public class testScript : MonoBehaviour
{
int i = 1;
// Use this for initialization
void Start()
{
for (i = 1; i > 6; i++)
{
Debug.Log("value of i = " + i);
}
Debug.Log("i'm out of the loop");
} //the problem is cs1513 c# expected unity here(21.line)
// Update is called once per frame
void Update()
{
}
}//<====This you missed.
answered Aug 10, 2016 at 5:35
ProgrammerProgrammer
122k22 gold badges237 silver badges329 bronze badges
0
Введение
Unity — это мощный игровой движок, который предоставляет возможность разработки разнообразных игр и виртуальных сред. Однако, при разработке проектов на Unity можно столкнуться с ошибками, которые могут вызвать затруднения в работе. В данной статье рассмотрены две типичные ошибки — CS1513 и CS1002, и представлены их решения.
Ошибка CS1513
Ошибка CS1513 » } expected» возникает, когда отсутствует закрывающая фигурная скобка в коде Unity. Эта ошибка указывает на то, что компилятор ожидает символа ‘}’, который закрывает блок кода.
Решение ошибки CS1513
Ключевым моментом решения ошибки CS1513 является обнаружение отсутствия закрывающей фигурной скобки. Для этого следует внимательно просмотреть код и убедиться, что каждая открывающая фигурная скобка имеет соответствующую закрывающую фигурную скобку. Если скобка не найдена, требуется добавить ее на соответствующем месте в коде.
Пример кода с ошибкой CS1513:
void Start()
{
if (condition)
{
// some code
// missing closing brace
// missing closing brace for Start() method
Код с исправлением ошибки CS1513:
void Start()
{
if (condition)
{
// some code
}
}
Ошибка CS1002
Ошибка CS1002 » ; expected» возникает, когда пропущена точка с запятой в коде Unity. Эта ошибка указывает на то, что компилятор ожидает символ ‘;’, который обозначает конец оператора.
Решение ошибки CS1002
Чтобы исправить ошибку CS1002, необходимо найти место, где пропущена точка с запятой, и добавить ее в соответствующем месте в коде.
Пример кода с ошибкой CS1002:
void Update()
{
var speed = 10
transform.Translate(speed * Time.deltaTime, 0, 0)
}
Код с исправлением ошибки CS1002:
void Update()
{
var speed = 10;
transform.Translate(speed * Time.deltaTime, 0, 0);
}
Заключение
Ошибки CS1513 и CS1002 могут возникать при разработке проектов на Unity, но они являются типичными и их исправление не представляет сложности. Важно правильно распознать причину ошибки и аккуратно внести необходимые исправления. Соблюдая правила написания кода и внимательно анализируя сообщения об ошибках, разработчики Unity смогут избежать этих проблем и сохранить свою продуктивность.
StAsIk2008 0 / 0 / 0 Регистрация: 20.02.2020 Сообщений: 1 |
||||
1 |
||||
20.02.2020, 13:09. Показов 15304. Ответов 3 Метки нет (Все метки)
вот скрипт
0 |
управление сложностью 1687 / 1300 / 259 Регистрация: 22.03.2015 Сообщений: 7,545 Записей в блоге: 5 |
|
20.02.2020, 13:38 |
2 |
Пропущена закрывающая скобка, либо лишняя открывающая
0 |
11 / 9 / 8 Регистрация: 08.05.2013 Сообщений: 140 |
|
20.02.2020, 14:55 |
3 |
На какую строку ругается?
0 |
0 / 0 / 0 Регистрация: 17.02.2020 Сообщений: 87 |
|
24.02.2020, 11:53 |
4 |
В конец поставь знак }
0 |
In this article we will learn about some of the frequently asked C# programming questions in technical like “how to fix error cs1513 in unity” Code Answer. This article will show you simple practices on dealing with performance problems, starting with when you need to deal with them at all. You will see techniques to detect if a problem exists, find the specific cause, and fix it. Below are some solution about “how to fix error cs1513 in unity” Code Answer.
how to fix error cs1513 in unity
Related posts:
I was programming (C#) a day/night cycle system for my unity game when I got the following error:Assets\Scripts\Rotate.cs(15,6): error CS1513: } expected
My code should calculate a ‘time’ in minutes from the rotation of the sun (Which is attached to this object).
Here is my code:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Rotate : MonoBehaviour { public float timescale=1f; private int hour=12; private int minute=0; void Start() { StartCoroutine("TickUpdate"); } public IEnumerator TickUpdate() { private string stringbuffer1; for(;;) { private float RotationSpeed 0.0025*timescale gameObject.transform.Rotate(RotationSpeed,0f,0f); public float RawMinute=0.00694444444444444444444444444444f*(gameObject.transform.rotation.x-90); public string time="{hour}:{minute}"; yield return new WaitForSeconds(.01f); } } }
I already checked multiple sites and the unity answers form.
Any help would be appericiated.
(I’m using Notepad++ as my editor)