/// <summary> /// Set up a Functionality Island and add it to the list of islands /// This must be done before the FunctionalityInjectionModule is loaded /// The recommended pattern is to implement IModuleDependency<FunctionalityInjectionModule> and add the /// island in ConnectDependency. If a hard dependency is not possible, ensure your module has a load order /// which is earlier than FunctionalityInjectionModule and add the island in LoadModule /// </summary> /// <param name="island">The functionality island to add to the list of islands</param> public void AddIsland(FunctionalityIsland island) { // Do not add the default island, as it will be added automatically if (island == m_DefaultIsland) { return; } Assert.IsFalse(m_Loaded, "It is too late to add a functionality island. All modules are loaded"); Assert.IsNotNull(island, "Trying to add an island that is null"); var wasAdded = m_Islands.Add(island); Assert.IsTrue(wasAdded, "Island has already been added"); island.Setup(); }
// We have to set up islands before the other modules get loaded so they can use FI internal void PreLoad() { if (!m_DefaultIsland) { #if UNITY_EDITOR DebugUtils.Log("You must set up a default functionality island. One has been created for you."); m_DefaultIsland = CreateInstance <FunctionalityIsland>(); AssetDatabase.CreateAsset(m_DefaultIsland, k_DefaultIslandPath); EditorUtility.SetDirty(this); if (!Application.isBatchMode) { AssetDatabase.SaveAssets(); } #else Debug.LogError("You must set up a default functionality island."); return; #endif } m_DefaultIsland.Setup(); m_Islands.Add(m_DefaultIsland); activeIsland = m_DefaultIsland; }