public async Task InitializeServiceAsync() { scriptLoader = new ScriptLoader(config.Loader, providersManager, localizationManager); if (!string.IsNullOrEmpty(config.GlobalDefinesScript)) { scriptLoader.GlobalDefinesScript = await scriptLoader.LoadAsync(config.GlobalDefinesScript); } if (CommunityModdingEnabled) { externalScriptLoader = new ScriptLoader(config.ExternalLoader, providersManager, localizationManager); externalScriptLoader.GlobalDefinesScript = scriptLoader.GlobalDefinesScript; } if (Application.isPlaying && config.EnableNavigator) { var navigatorPrefab = Resources.Load <UI.ScriptNavigatorPanel>(navigatorPrefabResourcesPath); navigatorUI = Engine.Instantiate(navigatorPrefab, "ScriptNavigator"); navigatorUI.SortingOrder = config.NavigatorSortOrder; navigatorUI.SetIsVisible(false); } if (string.IsNullOrEmpty(config.StartGameScript)) { var scriptPaths = await scriptLoader.LocateAsync(string.Empty); StartGameScriptName = scriptPaths.FirstOrDefault()?.Replace(scriptLoader.PathPrefix + "/", string.Empty); } else { StartGameScriptName = config.StartGameScript; } }
public async Task <Script> LoadScriptAsync(string name) { InvokeOnScriptLoadStarted(); if (scriptLoader.IsLoaded(name)) { InvokeOnScriptLoadCompleted(); return(scriptLoader.GetLoadedOrNull(name)); } var script = await scriptLoader.LoadAsync(name); InvokeOnScriptLoadCompleted(); return(script); }