transitionPhaseDuration

transitionPhaseDuration

在开发Unity游戏时,我将JavaScript代码转换为C#。我在将值分配给数组时陷入困境,我在JavaScript中工作得很好,但在C#中,它给出了以下错误“错误CS1525:意外符号','”
据我所知,语法没有错误。

这是JavaScript代码,可以正常工作:

public var primaryPhaseDuration = 20.0;
public var transitionPhaseDuration = 3.0;


function Start () {
stateIntervals =[primaryPhaseDuration,transitionPhaseDuration,transitionPhaseDuration,primaryPhaseDuration,transitionPhaseDuration,transitionPhaseDuration];
}


这是有错误的C#代码:

public float primaryPhaseDuration= 20.0f;
public float transitionPhaseDuration= 3.0f
void Start () {
    stateIntervals ={primaryPhaseDuration,transitionPhaseDuration,transitionPhaseDuration,primaryPhaseDuration,transitionPhaseDuration,transitionPhaseDuration};
}


我有谷歌它,但我发现是我正在使用相同的语法

最佳答案

请尝试以下代码:

stateIntervals= new float [] {1.0f, 2.0f, 3.0f};

08-27 22:52