The plyGame Global Object More...
Inherits MonoBehaviour.
Classes | |
class | LayerMapping |
Layers used in plyGame More... | |
class | Tag |
Tags used in plyGame More... | |
Public Types | |
enum | VolumeType { Main = 0, General = 1, GUI = 2, Effects = 3, Voice = 4, Ambient = 5, Music = 6, Custom1 = 7, Custom2 = 8, Custom3 = 9 } |
The available volume types. These are indexed to DataAsset.volume More... | |
Public Member Functions | |
void | LoadLanguageDependentData () |
Loads the Custom and Loading Screens. SelectedLanguage must be set. More... | |
ScriptableObject | GetAsset< T > () |
Get reference to an asset saved in dataAsset.assets list More... | |
void | RemoveAsset (ScriptableObject asset) |
Set null and remove and asset in dataAsset.assets list More... | |
void | ChangeSelectedResolution (bool increase) |
void | ApplySelectedResolution () |
string | GetSelectedResolution () |
void | SafeGFXSettings () |
void | LoadGFXSettings () |
void | UpdateAudioVolumes () |
Force volume update on listener (main) and all audio updaters. More... | |
void | ApplySoundVolumeChanges () |
Force volume update on listener (main) and all audio updaters. And SAVE the audio volume settings. More... | |
void | LoadSoundVolumeSettings () |
Force volume update on listener (main) and all audio updaters after loading audio volume settings More... | |
float | GetSoundVolume (GameGlobal.VolumeType type) |
void | ChangeSoundVolumeBy (GameGlobal.VolumeType type, int amount) |
void | PlayMusic (AudioClip music, bool onlyIfNonePlaying) |
void | StopMusic () |
void | SetAudioListenerFollow (GameObject go) |
Set the audio listener to follow the GameObject. Set null to stop following and move audio listener back to world 0x0x0. Only works on plyGame's default audio listener if it was left to be created by plyGame. More... | |
Static Public Member Functions | |
static void | Create () |
This is normally called in the Awake() of components that will need GameGlobal. Needed when designer press Unity play button. More... | |
static void | RegisterLoadSaveListener (GeneralCallback save, GeneralCallback load, GeneralCallback delete, GeneralCallback copy) |
Registers a callbacks to call when save: called when the listener should save data, load: called when the listener should load data, delete: called when the listener should delete data, copy: called when the listener should copy data from old load slot to current save slot More... | |
static void | RemoveLoadSaveListener (GeneralCallback save, GeneralCallback load, GeneralCallback delete, GeneralCallback copy) |
Remove a save, load and delete listener callbacks. profile and slot is passed as args if you need them. int profile = (int)args[0]; int slot = (int)args[1]; More... | |
static int | SetActiveProfile (string name) |
Set the profile and make it active. Will return the index of the new profile. return -1 on error. Profile indexes starts at 0. Sets active profile idx to that of the newly added profile. Will not create new profile but rather return index of existing if one of same name exist. More... | |
static void | SetActiveProfile (int profileIndex) |
Sets the active profile to one with specified index. Does not check if index is valid. Will reset active slot to slot 0. More... | |
static int | GetSavedProfileCount () |
Return the profile count (number of profiles that are saved) More... | |
static string | GetProfileName (int idx) |
Return the name of a saved profile. Return empty string if profile number not correct. More... | |
static void | SetActiveSaveSlot (int slot) |
Set the slot which will be used when calls are made to the LoadSave system. Try to keep to positive slot numbers if possible. Slot defaults to '-1' and is reserved to plyGame's test mode when no slot is specified. More... | |
static int | GetSavedSlotCount () |
Return the number of slots saved in the active LoadSave Profile. More... | |
static int | GetSavedSlotNumber (int index) |
Return the slot number of a saved slot. The index should be within 0 and GetSavedSlotCount. Return -1 if not found. More... | |
static string | GetActiveSlotDateTime () |
Return the Date and Time the slot was last saved. Return empty string if not yet saved. More... | |
static string | GetSlotDateTime (int slot) |
Return the Date and Time the slot was last saved. Return empty string if not yet saved. More... | |
static void | ResetLastLoadSlot () |
Should be called when the player starts a "new game". More... | |
static void | SaveGameSession () |
Saves the game state to active slot. Keys from Temp Store and active scene's persistent marked objects are stored. The default slot, '-1' will be prevented from being saved as it is used by plyGame when scenes are tested. More... | |
static void | LoadGameSession () |
Loads game state from active slot. The last active scene saved for this slot will be restored and all persistent-marked objects loaded from save. The default slot, '-1' will be prevented from being loaded as it is used by plyGame when scenes are tested. More... | |
static void | DeleteAllSaveData () |
Delete all saved data. More... | |
static void | DeleteProfile (int idx) |
Delete all data of a profile. This should not be called during active session as it will also remove all temporarily saved data and corrupt an active game session. Note: The active profile will be reset to 0 More... | |
static void | DeleteAllSlotsInActiveProfile () |
Delete all the slots (and their keys and values) from the specified profile. More... | |
static void | DeleteAllDataInActiveSlot () |
Delete all the keys and values from the specified slot. More... | |
static void | DeleteKey (string key) |
Delete a key from temp store key and permanently when SaveGameSession() is called. More... | |
static void | AddCreateLoadKey (System.Type objectType, string key) |
Add the key of an object that was added to scene at runtime and knows how to and would like to recreate itself in the scene when the player enters the scene again next time. More... | |
static void | RemoveCreateLoadKey (System.Type objectType, string key) |
Remove a key that was previously added via AddCreateLoadKey More... | |
static void | SetStringKey (string key, string value) |
Sets a value to the given key. This will be saved when SaveGameSession() is called. More... | |
static void | SetIntKey (string key, int value) |
Sets a value to the given key. This will be saved when SaveGameSession() is called. More... | |
static void | SetFloatKey (string key, float value) |
Sets a value to the given key. This will be saved when SaveGameSession() is called. More... | |
static void | SetBoolKey (string key, bool value) |
Sets a value to the given key. This will be saved when SaveGameSession() is called. More... | |
static void | SetVector2Key (string key, Vector2 value) |
Sets a value to the given key. This will be saved when SaveGameSession() is called. More... | |
static void | SetVector3Key (string key, Vector3 value) |
Sets a value to the given key. This will be saved when SaveGameSession() is called. More... | |
static void | SetVector4Key (string key, Vector4 value) |
Sets a value to the given key. This will be saved when SaveGameSession() is called. More... | |
static void | SetRectKey (string key, Rect value) |
Sets a value to the given key. This will be saved when SaveGameSession() is called. More... | |
static string | GetStringKey (string key, string defaultVal) |
Read a value from the given key. The current Save Slot is appended to the key. The LoadSave provider is checked if the key is not found in the temp store. defaultVal is returned if the key was not found in either location. More... | |
static int | GetIntKey (string key, int defaultVal) |
Read a value from the given key. The current Save Slot is appended to the key. The LoadSave provider is checked if the key is not found in the temp store. defaultVal is returned if the key was not found in either location. More... | |
static float | GetFloatKey (string key, float defaultVal) |
Read a value from the given key. The current Save Slot is appended to the key. The LoadSave provider is checked if the key is not found in the temp store. defaultVal is returned if the key was not found in either location. More... | |
static bool | GetBoolKey (string key, bool defaultVal) |
Read a value from the given key. The current Save Slot is appended to the key. The LoadSave provider is checked if the key is not found in the temp store. defaultVal is returned if the key was not found in either location. More... | |
static Vector2 | GetVector2Key (string key, Vector2 defaultVal) |
Read a value from the given key. The current Save Slot is appended to the key. The LoadSave provider is checked if the key is not found in the temp store. defaultVal is returned if the key was not found in either location. More... | |
static Vector3 | GetVector3Key (string key, Vector3 defaultVal) |
Read a value from the given key. The current Save Slot is appended to the key. The LoadSave provider is checked if the key is not found in the temp store. defaultVal is returned if the key was not found in either location. More... | |
static Vector4 | GetVector4Key (string key, Vector4 defaultVal) |
Read a value from the given key. The current Save Slot is appended to the key. The LoadSave provider is checked if the key is not found in the temp store. defaultVal is returned if the key was not found in either location. More... | |
static Rect | GetRectKey (string key, Rect defaultVal) |
Read a value from the given key. The current Save Slot is appended to the key. The LoadSave provider is checked if the key is not found in the temp store. defaultVal is returned if the key was not found in either location. More... | |
Public Attributes | |
GameObject | bloxGlobalFab |
GameObject | uiManagerFab |
InputDefAsset | inputAsset |
LanguagesAsset | langAsset |
SplashScreenAsset | splashAsset |
LangScreenAsset | langScrAsset |
LoadScreensAsset | loadScrAsset |
CustomScreensAsset | custScrAsset |
DataAsset | dataAsset |
Contains various definitions like Items and Equip Slots. | |
Static Public Attributes | |
static bool | EditorRunMode = false |
Protected Member Functions | |
void | Awake () |
void | LateUpdate () |
void | OnApplicationQuit () |
void | OnLevelWasLoaded (int level) |
Properties | |
static GameGlobal | Instance [get] |
Instance of the Game Global. More... | |
static bool | HasInstance [get] |
Return true if the instance exist, else false. More... | |
static bool | Paused [get, set] |
Indicates if game is considered paused or not. When paused the character controllers should not allow input, perform AI, or move the characters. There might be other systems that need to check this flag to decide when they should be active or not. More... | |
static plyBloxGlobal | BloxGlobal [get, set] |
Reference to the plyBlox Global. More... | |
static AudioListener | audioListener [get, set] |
The audio listener. More... | |
static AudioSource | musicSource [get, set] |
The music audio source. This is only valid if GameGlobal.PlayMusic() was called at least once. It is reused by GameGlobal.PlayMusic to play music. More... | |
GUIManager | uiManager [get, set] |
Instance of GUI/ Screens Manager. More... | |
string | language [get, set] |
"" (empty string) when default language is selected, else named language. More... | |
int | languageIdx [get, set] |
-1 when default language is selected, else 0,1,2,etc. More... | |
StringsAsset | stringsData [get, set] |
Strings data for currently selected language. More... | |
LoadSaveProviderBase | loadSaveProvider [get, set] |
Reference to the LoadSave Provider More... | |
string | loadSaveMainKey [get, set] |
This is the main key under which data is saved. It is a combination of the active profile and slot. Do not change this directly. It is updated when you set the active profile or slot via provided functions. More... | |
bool | isSessionRestore [get, set] |
The plyGame Global Object
The available volume types. These are indexed to DataAsset.volume
|
static |
Add the key of an object that was added to scene at runtime and knows how to and would like to recreate itself in the scene when the player enters the scene again next time.
void plyGame.GameGlobal.ApplySoundVolumeChanges | ( | ) |
Force volume update on listener (main) and all audio updaters. And SAVE the audio volume settings.
|
static |
This is normally called in the Awake() of components that will need GameGlobal. Needed when designer press Unity play button.
|
static |
Delete all the keys and values from the specified slot.
|
static |
Delete all saved data.
|
static |
Delete all the slots (and their keys and values) from the specified profile.
|
static |
Delete a key from temp store key and permanently when SaveGameSession() is called.
|
static |
Delete all data of a profile. This should not be called during active session as it will also remove all temporarily saved data and corrupt an active game session. Note: The active profile will be reset to 0
|
static |
Return the Date and Time the slot was last saved. Return empty string if not yet saved.
ScriptableObject plyGame.GameGlobal.GetAsset< T > | ( | ) |
Get reference to an asset saved in dataAsset.assets list
|
static |
Read a value from the given key. The current Save Slot is appended to the key. The LoadSave provider is checked if the key is not found in the temp store. defaultVal is returned if the key was not found in either location.
|
static |
Read a value from the given key. The current Save Slot is appended to the key. The LoadSave provider is checked if the key is not found in the temp store. defaultVal is returned if the key was not found in either location.
|
static |
Read a value from the given key. The current Save Slot is appended to the key. The LoadSave provider is checked if the key is not found in the temp store. defaultVal is returned if the key was not found in either location.
|
static |
Return the name of a saved profile. Return empty string if profile number not correct.
|
static |
Read a value from the given key. The current Save Slot is appended to the key. The LoadSave provider is checked if the key is not found in the temp store. defaultVal is returned if the key was not found in either location.
|
static |
Return the profile count (number of profiles that are saved)
|
static |
Return the number of slots saved in the active LoadSave Profile.
|
static |
Return the slot number of a saved slot. The index should be within 0 and GetSavedSlotCount. Return -1 if not found.
|
static |
Return the Date and Time the slot was last saved. Return empty string if not yet saved.
|
static |
Read a value from the given key. The current Save Slot is appended to the key. The LoadSave provider is checked if the key is not found in the temp store. defaultVal is returned if the key was not found in either location.
|
static |
Read a value from the given key. The current Save Slot is appended to the key. The LoadSave provider is checked if the key is not found in the temp store. defaultVal is returned if the key was not found in either location.
|
static |
Read a value from the given key. The current Save Slot is appended to the key. The LoadSave provider is checked if the key is not found in the temp store. defaultVal is returned if the key was not found in either location.
|
static |
Read a value from the given key. The current Save Slot is appended to the key. The LoadSave provider is checked if the key is not found in the temp store. defaultVal is returned if the key was not found in either location.
|
static |
Loads game state from active slot. The last active scene saved for this slot will be restored and all persistent-marked objects loaded from save. The default slot, '-1' will be prevented from being loaded as it is used by plyGame when scenes are tested.
void plyGame.GameGlobal.LoadLanguageDependentData | ( | ) |
Loads the Custom and Loading Screens. SelectedLanguage must be set.
void plyGame.GameGlobal.LoadSoundVolumeSettings | ( | ) |
Force volume update on listener (main) and all audio updaters after loading audio volume settings
|
static |
Registers a callbacks to call when save: called when the listener should save data, load: called when the listener should load data, delete: called when the listener should delete data, copy: called when the listener should copy data from old load slot to current save slot
args send to all are: args[0] = Profile IDX args[1] = Active Slot args[2] = [only for copy] Slot that data was last loaded from and should be copied from to active slot
Note. a main key is normally build from: (ProfileIDX + "." + ActiveSlot)
void plyGame.GameGlobal.RemoveAsset | ( | ScriptableObject | asset | ) |
Set null and remove and asset in dataAsset.assets list
|
static |
Remove a key that was previously added via AddCreateLoadKey
|
static |
Remove a save, load and delete listener callbacks. profile and slot is passed as args if you need them. int profile = (int)args[0]; int slot = (int)args[1];
|
static |
Should be called when the player starts a "new game".
|
static |
Saves the game state to active slot. Keys from Temp Store and active scene's persistent marked objects are stored. The default slot, '-1' will be prevented from being saved as it is used by plyGame when scenes are tested.
|
static |
Set the profile and make it active. Will return the index of the new profile. return -1 on error. Profile indexes starts at 0. Sets active profile idx to that of the newly added profile. Will not create new profile but rather return index of existing if one of same name exist.
|
static |
Sets the active profile to one with specified index. Does not check if index is valid. Will reset active slot to slot 0.
|
static |
Set the slot which will be used when calls are made to the LoadSave system. Try to keep to positive slot numbers if possible. Slot defaults to '-1' and is reserved to plyGame's test mode when no slot is specified.
void plyGame.GameGlobal.SetAudioListenerFollow | ( | GameObject | go | ) |
|
static |
Sets a value to the given key. This will be saved when SaveGameSession() is called.
|
static |
Sets a value to the given key. This will be saved when SaveGameSession() is called.
|
static |
Sets a value to the given key. This will be saved when SaveGameSession() is called.
|
static |
Sets a value to the given key. This will be saved when SaveGameSession() is called.
|
static |
Sets a value to the given key. This will be saved when SaveGameSession() is called.
|
static |
Sets a value to the given key. This will be saved when SaveGameSession() is called.
|
static |
Sets a value to the given key. This will be saved when SaveGameSession() is called.
|
static |
Sets a value to the given key. This will be saved when SaveGameSession() is called.
void plyGame.GameGlobal.UpdateAudioVolumes | ( | ) |
Force volume update on listener (main) and all audio updaters.
|
staticgetset |
The audio listener.
|
staticgetset |
Reference to the plyBlox Global.
|
staticget |
Return true if the instance exist, else false.
|
staticget |
Instance of the Game Global.
|
getset |
"" (empty string) when default language is selected, else named language.
|
getset |
-1 when default language is selected, else 0,1,2,etc.
|
getset |
This is the main key under which data is saved. It is a combination of the active profile and slot. Do not change this directly. It is updated when you set the active profile or slot via provided functions.
|
getset |
Reference to the LoadSave Provider
|
staticgetset |
The music audio source. This is only valid if GameGlobal.PlayMusic() was called at least once. It is reused by GameGlobal.PlayMusic to play music.
|
staticgetset |
Indicates if game is considered paused or not. When paused the character controllers should not allow input, perform AI, or move the characters. There might be other systems that need to check this flag to decide when they should be active or not.
|
getset |
Strings data for currently selected language.
|
getset |
Instance of GUI/ Screens Manager.