I working on a Unity Game, I converted JavaScript code to C#. I am stuck while assigning the values to an array, I works pretty fine in JavaScript but in C# it gives the following error " error CS1525: Unexpected symbol `,' " As i know there is no error in syntax.
This is JavaScript code and it works fine:
public var primaryPhaseDuration = 20.0;
public var transitionPhaseDuration = 3.0;
function Start () {
stateIntervals =[primaryPhaseDuration,transitionPhaseDuration,transitionPhaseDuration,primaryPhaseDuration,transitionPhaseDuration,transitionPhaseDuration];
}
Here is C# code which has the error:
public float primaryPhaseDuration= 20.0f;
public float transitionPhaseDuration= 3.0f
void Start () {
stateIntervals ={primaryPhaseDuration,transitionPhaseDuration,transitionPhaseDuration,primaryPhaseDuration,transitionPhaseDuration,transitionPhaseDuration};
}
I have google it but what i found was the same syntax i am using
请尝试以下代码:
stateIntervals= new float [] {1.0f, 2.0f, 3.0f};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.