using System; using UnityEngine; using Framework.Support; namespace Framework.Services { /// Provides access to game object holding the settings for a service public static class SettingsContainer { /// Retrieves the settings of the specified type /// Settings that will be created /// Scope in which the service will be created /// The requested component public static TComponent Get(string name) where TComponent : MonoBehaviour { GameObject container = Get(name); if(GameObjectHelper.IsNullOrDestroyed(container)) { return null; } else { return container.GetComponent(); } } /// Retrieves the setting root for the service with the specified name /// Scope for which the services root will be retrieved /// The services root for the specified scope public static GameObject Get(string name) { GameObject settingsRoot = SettingsRoot.Get(); if(GameObjectHelper.IsNullOrDestroyed(settingsRoot)) { return null; } else { return GameObjectHelper.GetChildByName(settingsRoot, name); } } } } // namespace Framework.Services