void FindColorGroups() { if (!ResolinkEditorSettings.Instance.GroupColors) { return; } k_ColorShortcutPrefixes.Clear(); k_RedColorShortcuts.Clear(); k_GreenColorShortcuts.Clear(); k_BlueColorShortcuts.Clear(); k_AlphaColorShortcuts.Clear(); foreach (var shortcut in m_Shortcuts) { var inPath = shortcut.Input.Path; if (Regexes.RedColorComponent.IsMatch(inPath)) { k_RedColorShortcuts.Add(shortcut); } else if (Regexes.GreenColorComponent.IsMatch(inPath)) { k_GreenColorShortcuts.Add(shortcut); } else if (Regexes.BlueColorComponent.IsMatch(inPath)) { k_BlueColorShortcuts.Add(shortcut); } else if (Regexes.AlphaColorComponent.IsMatch(inPath)) { k_AlphaColorShortcuts.Add(shortcut); } } AddToColorPrefixSet(k_RedColorShortcuts); AddToColorPrefixSet(k_GreenColorShortcuts); AddToColorPrefixSet(k_BlueColorShortcuts); AddToColorPrefixSet(k_AlphaColorShortcuts); foreach (var prefix in k_ColorShortcutPrefixes) { if (AllColorComponentsFound(prefix)) { var group = new ColorShortcutGroup() { Red = s_CurrentRedShortcut, Green = s_CurrentGreenShortcut, Blue = s_CurrentBlueShortcut, Alpha = s_CurrentAlphaShortcut }; k_ColorGroups.Add(group); m_Shortcuts.Remove(s_CurrentRedShortcut); m_Shortcuts.Remove(s_CurrentGreenShortcut); m_Shortcuts.Remove(s_CurrentBlueShortcut); m_Shortcuts.Remove(s_CurrentAlphaShortcut); } } }
public void SetHandlers(ColorShortcutGroup group) { Handlers[0].Shortcut = group.Red; Handlers[1].Shortcut = group.Green; Handlers[2].Shortcut = group.Blue; Handlers[3].Shortcut = group.Alpha; }
void DrawColorGroup(ColorShortcutGroup group) { DrawGroupedShortcut(group.Red, m_RedLabel); MaybeSeparator(); DrawGroupedShortcut(group.Green, m_GreenLabel); MaybeSeparator(); DrawGroupedShortcut(group.Blue, m_BlueLabel); MaybeSeparator(); DrawGroupedShortcut(group.Alpha, m_AlphaLabel); }
static void AddColorComponentIfAbsent(GameObject go, ColorShortcutGroup group, List <ColorOscEventHandler> components) { go.GetComponents(components); var found = false; foreach (var c in components) { if (c.Handlers == null) { continue; } if (c.Handlers[0].Shortcut != group.Red) { continue; } if (c.Handlers[1].Shortcut != group.Green) { continue; } if (c.Handlers[2].Shortcut != group.Blue) { continue; } if (c.Handlers[3].Shortcut != group.Alpha) { continue; } found = true; break; } if (!found) { var component = go.AddComponent <ColorOscEventHandler>(); component.Setup(); component.SetHandlers(group); } }