94 lines
2.8 KiB
C#
94 lines
2.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using EvolutStudio.tinysAPI.BaseClasses;
|
|
|
|
namespace EvolutStudio
|
|
{
|
|
namespace tinysAPI
|
|
{
|
|
public class Application : MonoBehaviour
|
|
{
|
|
|
|
#region Public Attributes
|
|
|
|
// global instance of the application manager
|
|
public static Application instance = null;
|
|
|
|
// public access to extension prefab references
|
|
public GameObject[] Extensions;
|
|
|
|
// public sub class for application notifications (for better readability)
|
|
public static class Notifications
|
|
{
|
|
public static string CHECKFORUPDATES = "application.checkforupdates";
|
|
public static string ASKTOINSTALLUPDATES = "application.asktoinstallupdate";
|
|
public static string INSTALLUPDATES = "application.installupdates";
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Private Attributes
|
|
|
|
// private attributes
|
|
|
|
#endregion
|
|
|
|
#region Public Functions
|
|
|
|
// public functions
|
|
|
|
public void notify(string notification, BaseClassView refView)
|
|
{
|
|
//TODO: wie wird was bekannt gemacht?
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Private Functions
|
|
|
|
[RuntimeInitializeOnLoadMethod]
|
|
static void OnRuntimeMethodLoad()
|
|
{
|
|
// notify user, tinysAPI is running and starts the application class
|
|
Debug.Log("tinysAPI: Starting Application");
|
|
|
|
//Instantiate the application prefab in the resources folder
|
|
Instantiate(Resources.Load("ApplicationInstance", typeof(GameObject)));
|
|
}
|
|
|
|
void Awake()
|
|
{
|
|
//Check if instance already exists
|
|
if (instance == null)
|
|
{
|
|
//if not, set instance to this
|
|
instance = this;
|
|
}
|
|
else if (instance != this)
|
|
{
|
|
//Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
|
|
Destroy(gameObject);
|
|
}
|
|
|
|
//Sets this to not be destroyed when reloading scene
|
|
DontDestroyOnLoad(gameObject);
|
|
|
|
// instanciate all extension prefabs
|
|
if(Extensions.Length != 0)
|
|
{
|
|
foreach(GameObject extension in Extensions)
|
|
{
|
|
Instantiate(extension, gameObject.transform.Find("Extensions").transform);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
}
|