Download presentation
Presentation is loading. Please wait.
Published byHengki Sudirman Modified over 6 years ago
1
Player preferences, Loading Scenes, Activating and Enabling
Unity Notes Player preferences, Loading Scenes, Activating and Enabling
2
Review Camera size is ½ screen height and width.
Images often have 100:1 pixel to unit ratio In 2D, z value is used for layering Object positions are world space for parents, object space for children Fields can be serialized rather than public Attaching BoxColliders registers objects for collision events
3
Player Preferences File stored on disk by unity
Keep player preferences between plays It’s really a hashtable
4
Using preferences bool PlayerPrefs.HasKey(String key) void PlayerPrefs.SetInt(String key, int value) void PlayerPrefs.SetFloat(String key, float value) void PlayerPrefs.SetString(String key, String value) int PlayerPrefs.GetInt(String key) etc…
5
Don’t duplicate data Usually a bad idea to store things in 2 different places – why? Don’t re-keep data in local variable without a good reason
6
Loading Scenes need using statement: using UnityEngine.SceneManagement; SceneManager is static object void SceneManager.LoadScene(String sceneName);
7
Runtime activation GameObjects can be activated and de-activated in code: gameObject.SetActive(false); When might you want to do this? You can check status as well: bool isActive = gameObject.activeSelf;
8
Runtime enabling Maybe you don’t want the whole object de-activated, but you do want to enable or disable one component of the object: myComponent = GetComponent<Whatever>(); myComponent.enabled = true;
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.