Search Unity

Fade in & Wait function don't work

Discussion in 'Scripting' started by Teroro, May 25, 2020.

  1. Teroro

    Teroro

    Joined:
    Mar 20, 2019
    Posts:
    40
    I am working in a game with 2 scenes for now and If I play the game from the first scene I get the fade in the first scenee but in the second scene I don't get the fade at the start and also In the second scene the wait function won't countdown If I play from scene 1.
    But if I play in the scene 2 directly I get the fade and the wait function start countdown when needed.
     
  2. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    1,556
    Perhaps you want to show us some code? Most of us here really suck at mind reading, me included. So in order to get some hints, we rely on old-fashioned code (and please use code tags).
     
  3. Teroro

    Teroro

    Joined:
    Mar 20, 2019
    Posts:
    40
    The code for wait its this one
    Line 81 - 90

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class RoboScript : MonoBehaviour
    6. {
    7.     public GameObject[] popUps;
    8.     private int popUpIndex;
    9.     public float waitTime = 5f;
    10.      public float waitTime1 = 10f;
    11.     public int callGloba;
    12.     public GameObject addObj;
    13.     public GameObject addObj1;
    14.     public GameObject addObj2;
    15.     public GameObject addObj3;
    16.     public GameObject addObj4;
    17.     public void OnClick()
    18.     {
    19.  
    20.         if (popUpIndex == 2)
    21.         { popUpIndex++; }
    22.  
    23.     }
    24.  
    25.     void Start()
    26.     {
    27.         addObj.SetActive(false);
    28.         addObj1.SetActive(false);
    29.         addObj2.SetActive(false);
    30.     }
    31.     private void Update()
    32.     {
    33.         callGloba = Level2.yos;
    34.         for (int i = 0; i < popUps.Length; i++)
    35.         {
    36.             if (i == popUpIndex)
    37.             {
    38.                 popUps[i].SetActive(true);
    39.             }
    40.             else
    41.             {
    42.                 popUps[i].SetActive(false);
    43.             }
    44.         }
    45.         if (popUpIndex == 0)
    46.         {
    47.             if (Input.GetMouseButtonDown(0))
    48.             {
    49.                 popUpIndex++;
    50.             }
    51.         }
    52.         else if (popUpIndex == 1)
    53.         {
    54.             addObj.SetActive(true);
    55.             if (callGloba >= 1)
    56.             {
    57.                 popUpIndex++;
    58.             }
    59.         }
    60.         else if (popUpIndex == 2)
    61.         {
    62.             addObj.SetActive(false);
    63.             addObj4.SetActive(true);
    64.         }
    65.         else if (popUpIndex == 3)
    66.         {
    67.             addObj2.SetActive(true);
    68.             addObj4.SetActive(false);
    69.             addObj1.SetActive(true);
    70.             if (callGloba == 0)
    71.             {
    72.                 popUpIndex++;
    73.             }
    74.         }
    75.         else if (popUpIndex == 4)
    76.         {
    77.             addObj1.SetActive(false);
    78.             addObj.SetActive(true);
    79.             addObj2.SetActive(true);
    80.             Debug.Log("Hello1");
    81.             if(waitTime1 <= 0)
    82.             {
    83.                 Debug.Log("Merge?");
    84.                 if (callGloba >= 10)
    85.                 {
    86.                     popUpIndex++;
    87.                 }
    88.             } else
    89.             {
    90.                 waitTime1 -= Time.deltaTime;
    91.             }
    92.         }
    93.         else if (popUpIndex == 5)
    94.         {
    95.             addObj.SetActive(false);
    96.             addObj1.SetActive(false);
    97.             addObj2.SetActive(false);
    98.             addObj3.SetActive(false);
    99.             if (waitTime <= 0)
    100.             {
    101.                 if (Input.GetMouseButtonDown(0))
    102.                 {
    103.                     addObj.SetActive(true);
    104.                     addObj1.SetActive(true);
    105.                     addObj2.SetActive(true);
    106.                     addObj3.SetActive(true);
    107.                     callGloba = 0;
    108.                     popUpIndex++;
    109.                 }
    110.             }
    111.             else
    112.             {
    113.                 waitTime -= Time.deltaTime;
    114.             }
    115.         }
    116.         else if (popUpIndex == 6)
    117.         {
    118.             if (callGloba >= 69)
    119.             {
    120.                 popUpIndex++;
    121.             }
    122.         }
    123.     }
    124. }

    The Animation has no script just this
    upload_2020-5-25_19-49-22.png
    upload_2020-5-25_19-49-44.png upload_2020-5-25_19-50-0.png