public override void Start() { base.Start(); string name = string.Format("{0} #{1}", Connector.KMBombModule.ModuleDisplayName, Connector.ModuleID); _gameInfo = GetComponent <KMGameInfo>(); _bombInfo = GetComponent <KMBombInfo>(); _translation = GetComponent <TranslatedTheButton> (); _translation.GenerateLanguage(name); LanguageTheButton language = _translation.Language; // Sets the appearance of the button Connector.SetColour(_color = (ButtonColour)Random.Range(0, 4)); _label = (ButtonLabel)Random.Range(0, 4); if (_translation.Language.DisplayMethod == LanguageTheButton.DisplayMethods.CustomTextMesh) { Connector.SetLabel(language.GetLabelFromEnglishName(_label.ToString()), language.Font, language.FontMaterial, language.GetSizeFromEnglishName(_label.ToString())); } else { Connector.SetLabel(language.GetLabelFromEnglishName(_label.ToString())); } LogFormat(language.RuleColorIs, language.GetLogFromEnglishName(_color.ToString())); LogFormat(language.RuleLabelIs, language.GetLogFromEnglishName(_label.ToString())); LogFormat(language.RuleButtonShouldBe, (ShouldBeHeld() ? language.RuleHeld : language.RulePressed)); // Register button hold and released events Connector.Held += Button_In; Connector.Released += Button_Out; // todo: this seems not needed anymore. Maybe for sprites. // Hide our custom text mesh/sprite in the dark. //if (_translation.Language.DisplayMethod != LanguageTheButton.DisplayMethods.Default) { // if (_color == ButtonColour.Blue || _color == ButtonColour.Red) { // _gameInfo.OnLightsChange += Connector.ToggleLabel; // Connector.ToggleLabel(false); // } //} TwitchHelpMessage = string.Format("{1}, {2} - !{0} tap | !{0} hold | !{0} release 7 (releases when there's a 7 in the timer)", "{0}", _translation.Language.NativeName, _translation.Language.Name); // Stuff regarding the cover var moduleSelectable = GetComponent <KMSelectable>(); _buttonSelectable = moduleSelectable.Children[0]; moduleSelectable.OnHighlight = () => { if (OpenCoverOnSelection) { Connector.OpenCover(); } }; _buttonSelectable.OnHighlight = () => { if (OpenCoverOnSelection) { Connector.OpenCover(); } }; moduleSelectable.OnHighlightEnded = () => { if (OpenCoverOnSelection) { Connector.CloseCover(); } }; _buttonSelectable.OnHighlightEnded = () => { if (OpenCoverOnSelection) { Connector.CloseCover(); } }; moduleSelectable.OnCancel = () => { Connector.CloseCover(); return(true); }; // Twitch Plays if (Application.isEditor) { // Things work a bit differently in the test harness from the actual game. // TODO: There is currently an issue whereby going from one module to another does not call any event. moduleSelectable.OnInteract = () => { if (!OpenCoverOnSelection) { Connector.OpenCover(); } return(true); }; } else { OpenCoverOnSelection = Connector.ShouldOpenCoverOnSelection; moduleSelectable.OnFocus = () => { if (!OpenCoverOnSelection) { Connector.OpenCover(); } }; moduleSelectable.OnDefocus = () => Connector.CloseCover(); } }