All Classes Namespaces Functions Variables Enumerations Enumerator Properties
plyGame.GameGlobal Class Reference

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]
 

Detailed Description

The plyGame Global Object

Member Enumeration Documentation

The available volume types. These are indexed to DataAsset.volume

Member Function Documentation

static void plyGame.GameGlobal.AddCreateLoadKey ( System.Type  objectType,
string  key 
)
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 void plyGame.GameGlobal.Create ( )
static

This is normally called in the Awake() of components that will need GameGlobal. Needed when designer press Unity play button.

static void plyGame.GameGlobal.DeleteAllDataInActiveSlot ( )
static

Delete all the keys and values from the specified slot.

static void plyGame.GameGlobal.DeleteAllSaveData ( )
static

Delete all saved data.

static void plyGame.GameGlobal.DeleteAllSlotsInActiveProfile ( )
static

Delete all the slots (and their keys and values) from the specified profile.

static void plyGame.GameGlobal.DeleteKey ( string  key)
static

Delete a key from temp store key and permanently when SaveGameSession() is called.

static void plyGame.GameGlobal.DeleteProfile ( int  idx)
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 string plyGame.GameGlobal.GetActiveSlotDateTime ( )
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 bool plyGame.GameGlobal.GetBoolKey ( string  key,
bool  defaultVal 
)
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 float plyGame.GameGlobal.GetFloatKey ( string  key,
float  defaultVal 
)
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 int plyGame.GameGlobal.GetIntKey ( string  key,
int  defaultVal 
)
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 string plyGame.GameGlobal.GetProfileName ( int  idx)
static

Return the name of a saved profile. Return empty string if profile number not correct.

static Rect plyGame.GameGlobal.GetRectKey ( string  key,
Rect  defaultVal 
)
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 int plyGame.GameGlobal.GetSavedProfileCount ( )
static

Return the profile count (number of profiles that are saved)

static int plyGame.GameGlobal.GetSavedSlotCount ( )
static

Return the number of slots saved in the active LoadSave Profile.

static int plyGame.GameGlobal.GetSavedSlotNumber ( int  index)
static

Return the slot number of a saved slot. The index should be within 0 and GetSavedSlotCount. Return -1 if not found.

static string plyGame.GameGlobal.GetSlotDateTime ( int  slot)
static

Return the Date and Time the slot was last saved. Return empty string if not yet saved.

static string plyGame.GameGlobal.GetStringKey ( string  key,
string  defaultVal 
)
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 Vector2 plyGame.GameGlobal.GetVector2Key ( string  key,
Vector2  defaultVal 
)
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 Vector3 plyGame.GameGlobal.GetVector3Key ( string  key,
Vector3  defaultVal 
)
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 Vector4 plyGame.GameGlobal.GetVector4Key ( string  key,
Vector4  defaultVal 
)
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 void plyGame.GameGlobal.LoadGameSession ( )
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 void plyGame.GameGlobal.RegisterLoadSaveListener ( GeneralCallback  save,
GeneralCallback  load,
GeneralCallback  delete,
GeneralCallback  copy 
)
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 void plyGame.GameGlobal.RemoveCreateLoadKey ( System.Type  objectType,
string  key 
)
static

Remove a key that was previously added via AddCreateLoadKey

static void plyGame.GameGlobal.RemoveLoadSaveListener ( GeneralCallback  save,
GeneralCallback  load,
GeneralCallback  delete,
GeneralCallback  copy 
)
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 void plyGame.GameGlobal.ResetLastLoadSlot ( )
static

Should be called when the player starts a "new game".

static void plyGame.GameGlobal.SaveGameSession ( )
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 int plyGame.GameGlobal.SetActiveProfile ( string  name)
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 void plyGame.GameGlobal.SetActiveProfile ( int  profileIndex)
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 void plyGame.GameGlobal.SetActiveSaveSlot ( int  slot)
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)

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.

static void plyGame.GameGlobal.SetBoolKey ( string  key,
bool  value 
)
static

Sets a value to the given key. This will be saved when SaveGameSession() is called.

static void plyGame.GameGlobal.SetFloatKey ( string  key,
float  value 
)
static

Sets a value to the given key. This will be saved when SaveGameSession() is called.

static void plyGame.GameGlobal.SetIntKey ( string  key,
int  value 
)
static

Sets a value to the given key. This will be saved when SaveGameSession() is called.

static void plyGame.GameGlobal.SetRectKey ( string  key,
Rect  value 
)
static

Sets a value to the given key. This will be saved when SaveGameSession() is called.

static void plyGame.GameGlobal.SetStringKey ( string  key,
string  value 
)
static

Sets a value to the given key. This will be saved when SaveGameSession() is called.

static void plyGame.GameGlobal.SetVector2Key ( string  key,
Vector2  value 
)
static

Sets a value to the given key. This will be saved when SaveGameSession() is called.

static void plyGame.GameGlobal.SetVector3Key ( string  key,
Vector3  value 
)
static

Sets a value to the given key. This will be saved when SaveGameSession() is called.

static void plyGame.GameGlobal.SetVector4Key ( string  key,
Vector4  value 
)
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.

Property Documentation

AudioListener plyGame.GameGlobal.audioListener
staticgetset

The audio listener.

plyBloxGlobal plyGame.GameGlobal.BloxGlobal
staticgetset

Reference to the plyBlox Global.

bool plyGame.GameGlobal.HasInstance
staticget

Return true if the instance exist, else false.

GameGlobal plyGame.GameGlobal.Instance
staticget

Instance of the Game Global.

string plyGame.GameGlobal.language
getset

"" (empty string) when default language is selected, else named language.

int plyGame.GameGlobal.languageIdx
getset

-1 when default language is selected, else 0,1,2,etc.

string plyGame.GameGlobal.loadSaveMainKey
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.

LoadSaveProviderBase plyGame.GameGlobal.loadSaveProvider
getset

Reference to the LoadSave Provider

AudioSource plyGame.GameGlobal.musicSource
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.

bool plyGame.GameGlobal.Paused
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.

StringsAsset plyGame.GameGlobal.stringsData
getset

Strings data for currently selected language.

GUIManager plyGame.GameGlobal.uiManager
getset

Instance of GUI/ Screens Manager.