Search Unity

error CS1525

Discussion in 'Scripting' started by Leandre5, Aug 7, 2019.

  1. Leandre5

    Leandre5

    Joined:
    Nov 1, 2017
    Posts:
    42
    Hello everyone I have the error CS1525 and I can't find the problem despite several searches

    Code (CSharp):
    1.         IEnumerator AnimationCaisseVert ()
    2.  
    3.         {
    4.                 FondNoir.SetActive(true);
    5.                 ImagecaisseVerte.SetActive(true);
    6.                 yield return new WaitForSeconds(1.2f);
    7.                 openingVerte.SetTrigger("Go");
    8.                 yield return new WaitForSeconds(1.2f);
    9.  
    10.                 int rand = Random.Range(0, 100);
    11.  
    12.                 if ( rand <= 50)
    13.                 {
    14.                         /// ExtraLife
    15.                         Extralife.SetActive(true);
    16.                         openingExtralife.SetTrigger("Go");
    17.                 }
    18.                 if ( rand > 50)
    19.                 {
    20.                         /// gold
    21.                         Gold.SetActive(true);
    22.                         openingGold.SetTrigger("Go");
    23.                 }
    24.         }
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    The error should have more information and tell you the specific line. It would be helpful if you'd include that information here with your question.
     
    SparrowGS likes this.
  3. Leandre5

    Leandre5

    Joined:
    Nov 1, 2017
    Posts:
    42
    Unexpected symbol `(', expecting `,', `;', or `='
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    But what line in the above code? It says so in the error. In the console you can even click on the error and it brings you to the line of code. I have a feeling it is in code other than what you have posted, because I don't see it.
     
    SparrowGS likes this.
  5. Leandre5

    Leandre5

    Joined:
    Nov 1, 2017
    Posts:
    42
    No, it's the right line and that's why I'm wondering because I don't see the error either.

    Assets/Scripts/OpeningCaisse.cs(199,33): error CS1525: Unexpected symbol `(', expecting `,', `;', or `='

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. public class OpeningCaisse : MonoBehaviour {
    7.  
    8.         // Use this for initialization
    9.         private GameObject[] characterObjectList;
    10.         private GameObject Manager;
    11.         public int index;
    12.  
    13.         public Text TextVert;
    14.         public Text TextBleu;
    15.         public Text TextViolet;
    16.         public Text TextGold;
    17.  
    18.         public int NBCaisseVert;
    19.         public int NBCaisseBleu;
    20.         public int NBCaisseViolet;
    21.         public int NBCaisseGold;
    22.         public int  NBCaisseGeneral;
    23.  
    24.         /// les animation
    25.         public Animator openingVerte;
    26.         public Animator openingGoldX2;
    27.         public Animator openingExtralife;
    28.         public Animator openingGold;
    29.  
    30.         /// les games object pour l'animation
    31.         public GameObject FondNoir;
    32.         public GameObject ImagecaisseVerte;
    33.         public GameObject ImagecaisseBleu;
    34.  
    35.  
    36.         public GameObject Extralife;
    37.         public GameObject GoldX2;
    38.         public GameObject Gold;
    39.  
    40.  
    41.         private void Awake ()
    42.         {
    43.  
    44.               Manager = GameObject.Find("GameManager").gameObject;
    45.  
    46.               /////////////////// mise a jour des valeurs
    47.                 NBCaisseGeneral = PlayerPrefs.GetInt("CaisseGeneral");
    48.                 NBCaisseVert = PlayerPrefs.GetInt("CaisseVert");
    49.                 NBCaisseBleu = PlayerPrefs.GetInt("CaisseBleu");
    50.                 NBCaisseViolet = PlayerPrefs.GetInt("CaisseViolet");
    51.                 NBCaisseGold = PlayerPrefs.GetInt("CaisseGold");
    52.  
    53.                 ////// mise à jour des text
    54.                 TextVert.text = NBCaisseVert + " ";
    55.                 TextBleu.text = NBCaisseBleu + " ";
    56.                 TextViolet.text =  NBCaisseViolet + " ";
    57.                 TextGold.text = NBCaisseGold + " ";
    58.  
    59.  
    60.                 ///// desactive tout pour l'Animation
    61.                 ImagecaisseVerte.SetActive(false);
    62.                 ImagecaisseBleu.SetActive(false);
    63.                 FondNoir.SetActive(false);
    64.                 Extralife.SetActive(false);
    65.                 GoldX2.SetActive(false);
    66.                 Gold.SetActive(false);
    67.  
    68.  
    69.  
    70.  
    71.                 index = 0;
    72.  
    73.                 characterObjectList = new GameObject[transform.childCount];
    74.  
    75.                 for(int i = 0; i < transform.childCount; i++)
    76.                 {
    77.                         characterObjectList[i] = transform.GetChild(i).gameObject;
    78.                 }
    79.  
    80.                 foreach (GameObject go in characterObjectList)
    81.                         go.SetActive(false);
    82.  
    83.                 if(characterObjectList[index])
    84.                             characterObjectList[index].SetActive(true);
    85.         }
    86. //////////////////////////Boutons des caisses ////////////
    87.  
    88.         public void CaisseVert()
    89.         {
    90.                 if ( index != 0 )
    91.                 {
    92.                         characterObjectList[index].SetActive(false);
    93.                         index = 0;
    94.                         characterObjectList[index].SetActive(true);
    95.                 }
    96.         }
    97.         public void CaisseBleu()
    98.         {
    99.                 if ( index != 1 )
    100.                 {
    101.                         characterObjectList[index].SetActive(false);
    102.                         index = 1;
    103.                         characterObjectList[index].SetActive(true);
    104.                 }
    105.         }
    106.         public void CaisseViolet()
    107.         {
    108.                 if ( index != 2 )
    109.                 {
    110.                         characterObjectList[index].SetActive(false);
    111.                         index = 2;
    112.                         characterObjectList[index].SetActive(true);
    113.                 }
    114.         }
    115.         public void CaisseGold()
    116.         {
    117.                 if ( index != 3 )
    118.                 {
    119.                         characterObjectList[index].SetActive(false);
    120.                         index = 3;
    121.                         characterObjectList[index].SetActive(true);
    122.                 }
    123.         }
    124.  
    125.         //////////////////// OUVERTURE DE LA CAISSE //////////////////
    126.  
    127.         public void Ouverture()
    128.         {
    129.                 if ( index == 0)
    130.                 {
    131.                         if ( NBCaisseVert > 0 )
    132.                         {
    133.                                 Debug.Log("la caisse verte à bien été ouverte");
    134.                                 NBCaisseVert -= 1;
    135.                                 TextVert.text = NBCaisseVert + " ";
    136.                                 PlayerPrefs.SetInt("CaisseVert", NBCaisseVert);
    137.                                 NBCaisseGeneral -= 1;
    138.                                 PlayerPrefs.SetInt("CaisseGeneral", NBCaisseGeneral);
    139.                                 ///// la caisse fais gagner tant de gold puis enregistre le nombre de gold
    140.                                 Manager.GetComponent<GameManager>().Gold +=1000000;
    141.                                 PlayerPrefs.SetInt("Gold", Manager.GetComponent<GameManager>().Gold);
    142.  
    143.                                 StartCoroutine(AnimationCaisseVert());
    144.  
    145.                         }
    146.                 }
    147.                 if ( index == 1)
    148.                 {
    149.                         if ( NBCaisseBleu > 0 )
    150.                         {
    151.                                 Debug.Log("la caisse bleu à bien été ouverte");
    152.                                 NBCaisseBleu -= 1;
    153.                                 TextBleu.text = NBCaisseBleu + " ";
    154.                                 PlayerPrefs.SetInt("CaisseBleu", NBCaisseBleu);
    155.                                 NBCaisseGeneral -= 1;
    156.                                 PlayerPrefs.SetInt("CaisseGeneral", NBCaisseGeneral);
    157.                                 ///// la caisse fais gagner tant de gold puis enregistre le nombre de gold
    158.                                 Manager.GetComponent<GameManager>().Gold += 1000000;
    159.                                 PlayerPrefs.SetInt("Gold", Manager.GetComponent<GameManager>().Gold);
    160.  
    161.                         }
    162.                 }
    163.                 if ( index == 2)
    164.                 {
    165.                         if ( NBCaisseViolet > 0 )
    166.                         {
    167.                                 Debug.Log("la caisse violet à bien été ouverte");
    168.                                 NBCaisseViolet -=1 ;
    169.                                 TextViolet.text = NBCaisseViolet + " ";
    170.                                 PlayerPrefs.SetInt("CaisseViolet", NBCaisseViolet);
    171.                                 NBCaisseGeneral -= 1;
    172.                                 PlayerPrefs.SetInt("CaisseGeneral", NBCaisseGeneral);
    173.                                 ///// la caisse fais gagner tant de gold puis enregistre le nombre de gold
    174.                                 Manager.GetComponent<GameManager>().Gold += 1000000;
    175.                                 PlayerPrefs.SetInt("Gold", Manager.GetComponent<GameManager>().Gold);
    176.  
    177.                         }
    178.                 }
    179.                 if ( index == 3)
    180.                 {
    181.                         if ( NBCaisseGold > 0 )
    182.                         {
    183.                                 Debug.Log("la caisse gold à bien été ouverte");
    184.                                 NBCaisseGold -= 1;
    185.                                 TextGold.text = NBCaisseGold + " ";
    186.                                 PlayerPrefs.SetInt("CaisseGold", NBCaisseGold);
    187.                                 NBCaisseGeneral -= 1;
    188.                                 PlayerPrefs.SetInt("CaisseGeneral", NBCaisseGeneral);
    189.                                 ///// la caisse fais gagner tant de gold puis enregistre le nombre de gold
    190.                                 Manager.GetComponent<GameManager>().Gold += 1001000000;
    191.                                 PlayerPrefs.SetInt("Gold", Manager.GetComponent<GameManager>().Gold);
    192.  
    193.                 }
    194.  
    195.         }
    196.  
    197.         /// toute les Animations
    198.  
    199.         IEnumerator AnimationCaisseVert ()
    200.  
    201.         {
    202.                 FondNoir.SetActive(true);
    203.                 ImagecaisseVerte.SetActive(true);
    204.                 yield return new WaitForSeconds(1.2f);
    205.                 openingVerte.SetTrigger("Go");
    206.                 yield return new WaitForSeconds(1.2f);
    207.  
    208.                 int rand = Random.Range(0, 100);
    209.  
    210.                 if ( rand <= 50)
    211.                 {
    212.                         /// ExtraLife
    213.                         Extralife.SetActive(true);
    214.                         openingExtralife.SetTrigger("Go");
    215.                 }
    216.                 if ( rand > 50)
    217.                 {
    218.                         /// gold
    219.                         Gold.SetActive(true);
    220.                         openingGold.SetTrigger("Go");
    221.                 }
    222.         }
    223.  
    224.  
    225. }
    226.  
     
  6. (line 181)

    The closing } is missing.
     
    SparrowGS and Joe-Censored like this.
  7. Leandre5

    Leandre5

    Joined:
    Nov 1, 2017
    Posts:
    42
    Thanks a lot
    I've been looking for hours.