2016-09-11 11 views
0

私が持っているスクリプトは、ゲームオブジェクト。エラーCS1525:私は同じエラー(31,16)の2持っている予期しないシンボル(', expecting)「,',を;」、[', or =」(31,16):エラーCS1525:予期しないシンボル `( '、' expecting`)、 `、 '、`;'、 `['、` =']

私はゲームオブジェクトを一時停止し、一時停止を解除しようとしています。私のシーンでは、一時停止やポーズ解除の可能性があります。私は、ゲームオブジェクトを数秒間一時停止し、一時停止させる必要があります。キーでゲームオブジェクトを一時停止することはできません。ここにスクリプトがあります:

using UnityEngine; 
using System.Collections; 

public class star : MonoBehaviour { 
GameObject[] pauseObjects; 


    void Start() { 
    pauseObjects = GameObject.FindGameObjectsWithTag("Player"); 
    } 

void Pause(){ 
    StartCoroutine(waitToUnpause); 
} 

IENumerator waitToUnpause(){ 
    //do the thing to pause game 
    Time.timeScale = 7f;//or some other method 
    yield return new WaitForSeconds(7);///or any duration you want 
    Time.timeScale = 1f;//or some other method 
} 

void pauseGameobject() 

{ 
timeLeft -= Time.deltaTime; 
if(timeLeft < 0) 
gameObject.SetActive(false); 
{ 

start coroutine("wait"); 

} 

} 

public ienumenator wait() 

{ 

time.timescale = 0; 

yield return new waitforsceonds(7); 

time.timesale = 1; 

} 
void pauseGameobject() 

{ 

if(timerleft < 0) 

{ 

start coroutine("wait"); 

} 

} 

public ienumenator wait() 

{ 

time.timescale = 0; 

yield return new waitforsceonds(7); 

time.timesale = 1; 

} 

} 
+1

コードをコピーしましたか?そうであれば、予期せぬシンボルのものとは別に構文エラーがあります。例えば。 'pauseGameobject'では' gameObject.SetActive(false) 'は' {'の直後でなく、ifの内部でなければなりません。また、間違った大文字/小文字やスペースではないはずのものもあります。 –

+0

これは正確なコードではない場合は、ファイルからコピーし、それを挿入すると、適切なインデントとエラーのそれぞれの行番号(stackoverflowのコードコマンド({ - アイコン)を使用することができますので、長いコードで数える必要があります)が役立ちます。 –

+0

私はそれをやったと思った。 – Freddy

答えて

0

このコードはエラーなしでコンパイルされています(あなたはかなり汚れています)。それは間違いなく動作しません。また、命名規則(大文字/小文字)に合わせていくつかの命名法を変更しました。

using UnityEngine; 
using System.Collections; 

public class Star : MonoBehaviour { 
    GameObject[] pauseObjects; 

    // I guess this variable is meant to be a field 
    // it is never set to any initial value! 
    float timeLeft; 

    void Start() { 
     pauseObjects = GameObject.FindGameObjectsWithTag("Player"); 
    } 

    void Pause(){ 
     StartCoroutine(WaitToUnpause()); 
    } 

    IEnumerator WaitToUnpause(){ 
     //do the thing to pause game 
     Time.timeScale = 7f;//or some other method 
     yield return new WaitForSeconds(7);///or any duration you want 
     Time.timeScale = 1f;//or some other method 
    } 

    void PauseGameobject() 

    { 
     timeLeft -= Time.deltaTime; 
     if(timeLeft < 0) 
     { 

      gameObject.SetActive(false); 
      StartCoroutine(Wait()); 

     } 

    } 

    public IEnumerator Wait() 

    { 

     Time.timeScale = 0; 

     yield return new WaitForSeconds(7); 

     Time.timeScale = 1; 

    } 

// The following code is nearly a duplicate of the above two functions 

// void PauseGameobject() 
// 
// { 
// 
//  if(timeleft < 0) 
// 
//  { 
// 
    //   StartCoroutine(Wait()); 
// 
//  } 
// 
// } 
// 
// public IEnumerator Wait() 
// 
// { 
// 
//  Time.timeScale = 0; 
// 
//  yield return new WaitForSeconds(7); 
// 
//  Time.timeScale = 1; 
// 
// } 

} 
関連する問題