/// <summary> /// A function that loads multiple files and delivers it as a single /// dictionary. Each file's contents should be a dictionary, and the /// resulting dictionary merges all the keys from all the /// dictionaries. Duplicate keys are overridden by later files in the /// index, same as if they were later keys in the same file. /// </summary> public static void LoadFilesAsMergedDict(string glob, ReloadDelegate cb) { var matchingFiles = FileManager.GetFilesByGlob(glob); var destFile = glob + "_file"; FileManager.RegisterCombinedFile(matchingFiles, destFile, CombineDict); FileManager.LoadConfig(destFile, cb); }
public static void CreateLuaFileWatcher(LuaEnv luaEnv) { var scriptPath = Path.Combine(Application.dataPath, PrePath); DirectoryWatcher.CreateWatch(scriptPath, new FileSystemEventHandler(OnLuaFileChanged)); _reloadFunction = luaEnv.Global.Get <ReloadDelegate>("hotfix"); EditorApplication.update -= Reload; EditorApplication.update += Reload; }
public static void CreateLuaFileWatcher(LuaEnv luaEnv) { var scriptPath = Path.Combine(Application.dataPath, "LuaScripts"); var directoryWatcher = new DirectoryWatcher(scriptPath, new FileSystemEventHandler(LuaFileOnChanged)); ReloadFunction = luaEnv.Global.Get <ReloadDelegate>("hotfix"); EditorApplication.update -= Reload; EditorApplication.update += Reload; }
public static void CreateLuaFileWatcher(LuaEnv luaenv) { var scriptPath = Path.Combine(Application.dataPath + LuaFilePath); if (directoryWatcher == null) { directoryWatcher = new DirectoryWatcher(scriptPath, new FileSystemEventHandler(OnLuaFileChange), ".lua"); } ReloadFunction = luaenv.Global.Get <ReloadDelegate>("hotfix"); EditorApplication.update -= OnReload; EditorApplication.update += OnReload; }
internal void RegisterReload(string filename, ReloadDelegate cb) { List <ReloadDelegate> delegates; if (!m_reloadCallbacks.TryGetValue(filename, out delegates)) { delegates = new List <ReloadDelegate>(); m_reloadCallbacks[filename] = delegates; } if (!delegates.Contains(cb)) { delegates.Add(cb); } }
/// <summary> /// Load a config file and call *cb* immediately with the contents. This also registers *cb* to /// be called every time the file is hotloaded. /// </summary> public void LoadConfig(string configName, ReloadDelegate cb) { CheckPreload(); if (!m_loadedFiles.ContainsKey(configName)) { throw new ConfigFileNotFoundException(configName); } bool save = cb(m_loadedFiles[configName].Parsed); if (save) { RegisterReload(configName, cb); } }
/// <summary> /// Load the configuration from *filename* by calling a callback. /// /// The callback *cb* is guaranteed to be called immediately when Load is called, /// and every time the file contents change. The function should return false /// to unsubscribe itself from future calls, true otherwise. /// /// Preloading must be complete before calling Load. /// </summary> public static void Load(string filename, ReloadDelegate cb) { FileManager.LoadConfig(filename, cb); }
static extern void InitManagedDelegates(RunDelegate run, ExecuteDelegate execute, ExecuteBackgroundDelegate executeBackground, ReloadDelegate reload, ListDelegate list);
public void CancelSourceMap(Layer layer, SourceMap sourceMap) { ReloadDelegate method = Reload; Invoke(method); }