Unityエラーセット(継続的な更新)



Unity Error Set




Assets / Script_02_01.cs(22,19):エラーCS0119:式は「タイプ」を示します。「変数」、「値」、または「メソッドグループ」が予期されていました。

  • エラーコード
GUI.backgroundColor = Color.red If (GUI.Button (Rect (10, 10, 70, 30), 'Rotate left')) { transform.Rotate (Vector3.up * Time.deltaTime * -rotateSpeed) }
  • 理由

    コードはJavascriptからC#に変換され、最も基本的な間違いを犯しました。 Rectオブジェクトを使用するには、jsではなくnewキーワードを使用する必要があります。



  • 正しいコード

GUI.backgroundColor = Color.red If (GUI.Button (new Rect (10, 10, 70, 30), 'Rotate left')) { transform.Rotate (Vector3.up * Time.deltaTime * -rotateSpeed) }

転載:https://www.jianshu.com/p/264f70deadea