private void AddCommand(string name, CommandInfo action) { if (!CommandsByName.ContainsKey(name)) { if (DebugLog) { Debug.Log("Adding new command: " + name); } CommandsByName.Add(name, action); if (action.HasQuickName) { if (!CommandsByName.ContainsKey(action.CommandQuickName)) { CommandsByName.Add(action.CommandQuickName, action); } else if (CommandsByName[action.CommandQuickName].CommandOrder > action.CommandOrder) { CommandsByName[action.CommandQuickName] = action; } } if (action.HasHotKeys) { HotKeysManager.RegisterCommandHotKey(action); } } }
public void RetrieveAllCommands(bool force = false) { /* if (!instance) * FindInstance();*/ try { if (DebugLog) { Debug.Log("Retrieving"); } if (!force) { if (CommandCount > 0) { if (DebugLog) { Debug.Log("Canceled because some commands already found"); } return; } if (commandsRetrieving != null) { if (commandsRetrieving.IsAlive) { if (DebugLog) { Debug.Log("Canceled because thread is alive"); } return; } } } if (IsLoading) { commandsRetrieving?.Abort(); } if (DebugLog) { Debug.Log("NOT CANCELED"); } EditorApplication.update -= AddAllFoundCommand; EditorApplication.update += AddAllFoundCommand; HotKeysManager.Reset(); lock (infoToAdd) { infoToAdd.Clear(); } onlyScanSpecified = MonKeyInternalSettings.Instance.OnlyScanSpecified; assembliesToExclude = MonKeyInternalSettings.Instance.ExcludedAssemblies.Split(';'); nameSpacesToExclude = MonKeyInternalSettings.Instance.ExcludedNameSpaces.Split(';'); CommandsByName.Clear(); TypeManager.Clear(); IsLoading = true; commandsRetrieving?.Abort(); commandsRetrieving = new Thread(CheckCommandsForAllAssemblies) { IsBackground = true, Priority = ThreadPriority.Normal, }; commandsRetrieving.Start(); } catch (Exception) { // Unity is not ready yet for instance creation return; } }