Inheritance: MonoBehaviour
    //restarts currently active scene
    public void Restart()
    {
        ScrollRectSnap scrollRectSnapScript = GameObject.Find("GameController").GetComponent <ScrollRectSnap>(); //creates a variable

        Generation.characterName = scrollRectSnapScript.charName;                                                //sets the current active character's name in the Generation script

        SceneManager.LoadScene(SceneManager.GetActiveScene().name);                                              //reloads scene
    }
    // Start is called before the first frame update
    void Start()
    {
        rectSnap = GetComponent <ScrollRectSnap>();
        // setting costs
        characterCosts.Add(new Cost(Cost.Type.fish, 0));
        characterCosts.Add(new Cost(Cost.Type.fish, 1000));
        characterCosts.Add(new Cost(Cost.Type.specialCurrency, 300));

        foreach (Transform t in scrollPanel.transform)
        {
            charactersDisplay.Add(t.GetComponent <Image>());
        }

        // reading saved data
        UpdateCharacters();

        lastSelectedCharacter = -1;
    }
Exemplo n.º 3
0
 private void OnGameDidLoad()
 {
     if (screens != null)
     {
         UnityEngine.UI.ScrollRect scrollRect = gameObject.GetComponent <UnityEngine.UI.ScrollRect>();
         ScrollRectSnap            scrollSnap = gameObject.GetComponent <ScrollRectSnap>();
         foreach (GameObject screenPrefab in screens)
         {
             GameObject screenObject = Instantiate(screenPrefab);
             screenObject.transform.SetParent(screenGrid.transform, false);
             BaseScrollScreen scrollScreen = screenObject.GetComponent <BaseScrollScreen>();
             if (scrollScreen != null && scrollRect != null && scrollSnap != null)
             {
                 scrollScreen.ScrollContainer     = scrollRect;
                 scrollScreen.ScrollSnapContainer = scrollSnap;
             }
         }
     }
 }