This is an old revision of the document!
Realizati o secventa de 3 scene in Unity cu urmatoarele functionalitati:
Inregistrare pe Teams
PlayerPrefs este o sectiune de setari statice, valabile pentru o aplicatie (un Player Unity, de unde si numele de PlayerPrefs). Asadar, PlayerPrefs este dedicat setarilor de player in general ca rezolutie, volum, etc, dar poate fi folosit in variante simple si pentru alte lucruri simple (de ex un username, daca este local).
Permite o salvare limitata ca dimensiune de valori Int, Float sau String intr-un index de tip key-value.
PlayerPrefs.SetInt("score",5); PlayerPrefs.SetFloat("volume",0.6f); PlayerPrefs.SetString("username","John Doe"); PlayerPrefs.Save(); int score = PlayerPrefs.GetInt("score"); float volume = PlayerPrefs.GetFloat("volume"); string player = PlayerPrefs.GetString("username");
Încărcarea unei noi Scene distruge toate obiectele Scenei curente. Astfel, puteti folosi Object.DontDestroyOnLoad pentru a păstra un obiect în timpul încărcării unei noi scene. Dacă obiectul țintă este o componentă sau GameObject, Unity păstrează, de asemenea, toți copiii din ierarhie. Object.DontDestroyOnLoad funcționează numai pentru GameObject root sau componente de pe GameObjects root (adica copii directi ai scenei in ierarhie).
using System.Collections; using System.Collections.Generic; using UnityEngine; public class MyPlayerClass: MonoBehaviour { void Awake() { DontDestroyOnLoad(gameObject); } }