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
121k22 gold badges234 silver badges324 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
121k22 gold badges234 silver badges324 bronze badges
0
StAsIk2008 0 / 0 / 0 Регистрация: 20.02.2020 Сообщений: 1 |
||||
1 |
||||
20.02.2020, 13:09. Показов 14773. Ответов 3 Метки нет (Все метки)
вот скрипт
0 |
управление сложностью 1687 / 1300 / 259 Регистрация: 22.03.2015 Сообщений: 7,545 Записей в блоге: 5 |
|
20.02.2020, 13:38 |
2 |
Пропущена закрывающая скобка, либо лишняя открывающая
0 |
11 / 9 / 8 Регистрация: 08.05.2013 Сообщений: 139 |
|
20.02.2020, 14:55 |
3 |
На какую строку ругается?
0 |
0 / 0 / 0 Регистрация: 17.02.2020 Сообщений: 87 |
|
24.02.2020, 11:53 |
4 |
В конец поставь знак }
0 |
Содержание
- Error cs1513 expected что это
- Answered by:
- Question
- Answers
- Error cs1513 expected что это
- Answered by:
- Question
- Answers
- All replies
- Error cs1513 expected что это
- Answered by:
- Question
- Answers
- All replies
- Error cs1513 expected что это
- Answered by:
- Question
- Answers
Error cs1513 expected что это
Answered by:
Question
This is the last two statements of my coding:>// closing a class statement>//closing a void statement.
No other errors. Message CS1513 three times repeated from csc compiler on the same line coding.
Answers
Error CS1513 shows that t he compiler expected a closing curly brace (>) that was not found.
The following sample generates CS1513:
namespace y // CS1513, no close curly brace
public static void Main()
If you still have any further concern , please post your code, we will try our best to help you to solve this issue.
Lucy Liu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Источник
Error cs1513 expected что это
This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.
Answered by:
Question
I am just starting university and have begun programming in C#, I have just run into an issue that I am unsure how to fix where compiling states that a > is expected on line 37, but when I fix this, a multitude of errors occur stating that:
A local or parameter named ‘Percentage’ cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter
Cannot convert lambda expression to type ‘bool’ because it is not a delegate type
Below is the area of code that is being changed
Any help regarding this error would be greatly appreciated
Answers
Try casting the values as floats:
The proper format of if with else if is in the link.
Here is the proper syntax:
You will have to rename the parameter «Percentage» to something like «percentage». The error tells you it is already used.
Let me know if that helps!
You hit an else before you hit a closing bracket here:
Control structures either govern the next block defined by brackets or only the code until the next Semikolon (wich means one line).
Your code put’s the else inside the if block. It is actually a peer of the if.
I guess you are missing closing bracket for if condition and else if condition. And else if end with else condition. Please try below code.
Hope this helps you.
I have tried your suggestions and I am now getting the error that occurred before when I tested it, with the command prompt outputting:
error CS0136: A local or parameter named ‘percentage’ cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter
error CS1660: Cannot convert lambda expression to type ‘bool’ because it is not a delegate type
Throughout the document, adding the curly bracket seems to break the program even worse.
Is this an easier fix or does this make the problem worse?
How can that be without an «else if»?
You can do the else.
I have tried your suggestions and I am now getting the error that occurred before when I tested it, with the command prompt outputting:
error CS0136: A local or parameter named ‘percentage’ cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter
error CS1660: Cannot convert lambda expression to type ‘bool’ because it is not a delegate type
Throughout the document, adding the curly bracket seems to break the program even worse.
Is this an easier fix or does this make the problem worse?
To fix the lambda problem, you must swat the «=>» to «>=» like in my code sample above.
Try renaming the Percentage variable just in the sample code you provided, or change » float Percentage = ( NumberofMarksInt / 70 ) * 100 ; » to » Percentage = ( NumberofMarksInt / 70 ) * 100 ; «. Drop the float in front of it. It was already defined.
That should fix it for you.
A control sturcture — be it an if, else, try, catch, switch, case, for or while — needs a clear definition for wich part of the code it applies. Indenting has no effect. Whitespaces have no effect.
You either define the area with curly brackets or it just takes everything until the next semikolon.
Without the proper braketing (the code you wrote in your OP) the syntax was so broken, the compiler could not even get to the real errors when looking at the code.
It was too broken to even properly find the real errors.
After you fixed the faulty brakets, you can now go deal with the real issues. Namely:
error CS0136: A local or parameter named ‘percentage’ cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter
error CS1660: Cannot convert lambda expression to type ‘bool’ because it is not a delegate type
CS0136 implies you already had a variable of that name defined. Show us the rest of your code, we might be able to spot it.
CS1660 complains about this combination «=>» That is the character combination that starts a lambda expression, not the «>=» (more or equal) sign. And lambdas really don’t belong into a if.
Источник
Error cs1513 expected что это
Answered by:
Question
Not sure why I am getting this error
This code has been in use for over a year, recently changed host and now getting compile error — error CS1513: > expected
Here is the code, which looks balanced for curly braces to me.
It is asking for another closing curly brace at the end.
Is this an issue of Webmatrix1 vs Webmatrix2 ?
Any help please — much appreciated.
Answers
My only thought is that something within the Layout page is causing this to occur.
I tried moving around some of the braces in the Layout page to see if that made any difference at all :
It’s possible that the semicolon issue is coming down from the Layout and the error is only been seen on the child-page level.
Do you have any other code that might be interferring with this? (The @ symbol can often throw off the curly braces and cause them to «miss» one another)
I tried the following code that you had below and it appeared to work just fine :
Thaks Rion
Yes it goes into another block as follows
The logic is if user is logged in then show their GiftAid status (which can be yes or no) else show the
Do you only need to display the actual
area or all of the code behind it?
Example with just Gift Aid
Example with entire section
(I removed the trailing ‘;’ after your RenderPage call, although I’m not around an environment to test it.)
removed the trailing ; but webmatrix still not happy and want another > at the end of first block of code — it gives line number and column number.
As I mentioned this code has been working for more than a year and now that I changed host this thing has cropped up, probably they have different compiler — Razor 2 ?
Ah you may want to ensure that you have the newest version of WebMatrix 2. (WebMatrix 3 was just released recently, although 2 should be sufficient)
Have you tried removing the Razor code blocks within your if-else blocks to see if that makes any difference at all? (Sometimes they can throw things off a bit) :
I did that and found out that it is the top code between @ < >that is the problem. The error goes away if I remove the top block but stays if I remove the @if block.
I noticed that before as well by the colour that it is not extending to the 2nd > where it should .
Regarding Webmatrix 2, yes I do have that uptodate which I regret because after the update the Webdeploy stopped working and hasn’t worked since despite pestering the hosts many times, and they say it is fine on their end. Therefore I changed the host and landed into more troubles, and webdeploy still dont work.
wasted a lot of time after the update without getting any real advantage.
Источник
Error cs1513 expected что это
Answered by:
Question
This is the last two statements of my coding:>// closing a class statement>//closing a void statement.
No other errors. Message CS1513 three times repeated from csc compiler on the same line coding.
Answers
Error CS1513 shows that t he compiler expected a closing curly brace (>) that was not found.
The following sample generates CS1513:
namespace y // CS1513, no close curly brace
public static void Main()
If you still have any further concern , please post your code, we will try our best to help you to solve this issue.
Lucy Liu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Источник
C++ Error 1513-1514
Всем привет, я новичок как в Unity так и в C++.
Прошу вашей помощи, импортировал ассет на что Unity пожаловался на скрипт, многие ошибки устранил но вот две ошибки не получается, вот эти «error CS1514: { expected и error CS1513: } expected»
Вот сам скрипт:
Используется csharp
using UnityEngine;
using CharacterMotor;
public class CharacterMotor;
public class StepsHandlerExample : MonoBehaviour
{
private CharacterMotor charMot;
private Vector3 displacement;
private float iniBackSpeed;
private float iniForSpeed;
private float iniSideSpeed;
private Vector3 lastPos;
private float slowBackSpeed;
private float slowForSpeed;
private float slowSideSpeed;
public float slowWalkVolume = 0.1f;
private bool onetime;
public float normalWalkRate = 0.7f;
public float slowWalkRate = 1.5f;
private void Start()
{
lastPos = transform.position;
charMot = GetComponent<CharacterMotor>();
iniForSpeed = charMot.movement.maxForwardSpeed;
iniBackSpeed = charMot.movement.maxBackwardsSpeed;
iniSideSpeed = charMot.movement.maxSidewaysSpeed;
slowBackSpeed = charMot.movement.maxBackwardsSpeed — 6.0f;
slowForSpeed = charMot.movement.maxForwardSpeed — 7.0f;
slowSideSpeed = charMot.movement.maxSidewaysSpeed — 5.0f;
}
private void Update()
{
if (Input.GetKey(KeyCode.LeftShift))
{
GetComponent<AudioSource>().volume = slowWalkVolume;
charMot.movement.maxForwardSpeed = slowForSpeed;
charMot.movement.maxBackwardsSpeed = slowBackSpeed;
charMot.movement.maxSidewaysSpeed = slowSideSpeed;
if (onetime)
{
onetime = false;
CancelInvoke(«NormalWalk»);
InvokeRepeating(«NormalWalk», 0f, slowWalkRate);
}
}
else
{
GetComponent<AudioSource>().volume = 1f;
charMot.movement.maxForwardSpeed = iniForSpeed;
charMot.movement.maxBackwardsSpeed = iniBackSpeed;
charMot.movement.maxSidewaysSpeed = iniSideSpeed;
if (!onetime)
{
onetime = true;
CancelInvoke(«NormalWalk»);
InvokeRepeating(«NormalWalk», 0f, normalWalkRate);
}
}
}
private void NormalWalk()
{
displacement = transform.position — lastPos;
lastPos = transform.position;
if (!charMot.IsJumping())
{
if (displacement.magnitude > 0.01)
{
if (!GetComponent<AudioSource>().isPlaying)
{
GetComponent<AudioSource>().Play();
}
}
}
}
private void OnGUI()
{
GUI.Box(new Rect(Screen.width/12, Screen.height — (Screen.height/4), Screen.width/1.1f, Screen.height/5),
«Hold Left Shift to walk slowly without noise! see the difference if you run behind the enemy!»);
}
}
Заранее всем спасибо большое.
- Shram
- UNец
- Сообщения: 5
- Зарегистрирован: 04 мар 2019, 14:02
Re: C++ Error 1513-1514
1max1 04 мар 2019, 15:16
Как насчет сходить уроки по с# почитать, глядишь сможешь отличать его от c++. К тому же, если ты и дальше планируешь развиваться, то код писать нужно в нормальной среде типа Visual Studio, которая будет подчеркивать строки с ошибками.
Что по твоему должна делать эта строка в твоем коде?
Используется csharp
public class CharacterMotor;
Конечно же ты не знаешь, потому что код-то не твой, ты его от куда-то взял в надежде на чудо, а разбираться не захотел
-
1max1 - Адепт
- Сообщения: 5426
- Зарегистрирован: 28 июн 2017, 10:51
Re: C++ Error 1513-1514
Friend123 04 мар 2019, 17:09
1max1, улыбнул )))))
-
Friend123 - Старожил
- Сообщения: 701
- Зарегистрирован: 26 фев 2012, 22:12
- Откуда: Тверь
-
- ICQ
Re: C++ Error 1513-1514
Shram 04 мар 2019, 18:32
1max1 писал(а):Как насчет сходить уроки по с# почитать, глядишь сможешь отличать его от c++. К тому же, если ты и дальше планируешь развиваться, то код писать нужно в нормальной среде типа Visual Studio, которая будет подчеркивать строки с ошибками.
Что по твоему должна делать эта строка в твоем коде?Используется csharp
public class CharacterMotor;
Конечно же ты не знаешь, потому что код-то не твой, ты его от куда-то взял в надежде на чудо, а разбираться не захотел
Конечно не мой умник, читай внимательно ! Написано же что был импортирован ассет и было около 6-и ошибок, они ссылались на «CharacterMotor»
а когда я кидаю другой скрипт «CharacterMotor» тогда появдяется другая ошибка, «The type or namespace name ‘ParticleAnimator’ could not be found (are you missing a using directive or an assembly reference?»
Затем пришел к этим единственным ошибкам.
Но я вижу здесь все злые.
- Shram
- UNец
- Сообщения: 5
- Зарегистрирован: 04 мар 2019, 14:02
Re: C++ Error 1513-1514
Friend123 04 мар 2019, 18:37
Shram писал(а):Но я вижу здесь все злые.
Это не мы злые, это вы, простите, задаете вопросы уровня 1 курса универа по программированию
Вот, если выдает ошибку, то в самой ошибке всегда сказано что не так, они все типовые. Простое гугление даст ответ в 10 раз быстрее, чем писать на форуме.
P.S. Как-то я думал всегда, что форумы для обсуждения сложных проблем. Ошибался видать.
-
Friend123 - Старожил
- Сообщения: 701
- Зарегистрирован: 26 фев 2012, 22:12
- Откуда: Тверь
-
- ICQ
Re: C++ Error 1513-1514
Shram 04 мар 2019, 18:47
Friend123 писал(а):
Shram писал(а):Но я вижу здесь все злые.
Это не мы злые, это вы, простите, задаете вопросы уровня 1 курса универа по программированию
Вот, если выдает ошибку, то в самой ошибке всегда сказано что не так, они все типовые. Простое гугление даст ответ в 10 раз быстрее, чем писать на форуме.
P.S. Как-то я думал всегда, что форумы для обсуждения сложных проблем. Ошибался видать.
P.S. а я думал почемучка для этого и была создана.
Ну хорошо, смотрите я создал новый проект импортировал ассет, на что он мне ответил ошибкой вот такую
«StepsHandlerExample.cs(5,13): error CS0246: The type or namespace name ‘CharacterMotor’ could not be found (are you missing a using directive or an assembly reference?»
И поверьте я пользовался «Google» проверил имя скрипта «CharacterMotor» совпадает, Google не чего не нашел.
- Shram
- UNец
- Сообщения: 5
- Зарегистрирован: 04 мар 2019, 14:02
Re: C++ Error 1513-1514
1max1 04 мар 2019, 19:40
Похоже автор твоего ассета забыл добавить скрипт CharacterMotor))
И поверьте я пользовался «Google» проверил имя скрипта «CharacterMotor» совпадает, Google не чего не нашел.
Что-то я тебе не верю)))
http://wiki.unity3d.com/index.php/CharacterMotor
-
1max1 - Адепт
- Сообщения: 5426
- Зарегистрирован: 28 июн 2017, 10:51
Re: C++ Error 1513-1514
Shram 04 мар 2019, 19:57
1max1 писал(а):Похоже автор твоего ассета забыл добавить скрипт CharacterMotor))
И поверьте я пользовался «Google» проверил имя скрипта «CharacterMotor» совпадает, Google не чего не нашел.
Что-то я тебе не верю)))
http://wiki.unity3d.com/index.php/CharacterMotor
Этот скрипт я находил и добавлял, но все же спасибо, но теперь вылезли еще ошибки, суть их схожая
«The type or namespace name ‘ParticleAnimator’ could not be found (are you missing a using directive or an assembly reference?»
Теперь я понял что значит Не удалось найти ссылка на сборку, нет тупа скрипта, я ведь правельно все понял ? Значит уже два скрипта он забыл положить ?
- Shram
- UNец
- Сообщения: 5
- Зарегистрирован: 04 мар 2019, 14:02
Re: C++ Error 1513-1514
Shram 04 мар 2019, 20:36
Ну да точно, ассет требует версию 4.6 теперь все понял.
Спасибо большое, вот теперь есть не большой как в скриптах так и в юнити.
- Shram
- UNец
- Сообщения: 5
- Зарегистрирован: 04 мар 2019, 14:02
Вернуться в Почемучка
Кто сейчас на конференции
Сейчас этот форум просматривают: Google [Bot], Yandex [Bot] и гости: 30
AssetsScriptsRotate.cs(15,6): error CS1513: } expected
I was programming (C#) a day/night cycle system for my unity game when I got the following error:AssetsScriptsRotate.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)
Archived post. New comments cannot be posted and votes cannot be cast.