private void LanguageCheckbox_OnChecked(LanguageToggle obj) { if ((obj != null) && (IsListeningToEvents == true)) { // Update the toggle to select currentSelectedCheckbox = obj; // Change the language Translations.CurrentLanguage = currentSelectedCheckbox.Language; } }
private LanguageToggle DuplicateToggle(LanguageToggle toggleToDuplicate) { // Clone the object GameObject clonedObject = Instantiate <GameObject>(toggleToDuplicate.gameObject); // Setup the transform clonedObject.transform.SetParent(toggleToDuplicate.transform.parent); clonedObject.transform.localRotation = Quaternion.identity; clonedObject.transform.localScale = Vector3.one; clonedObject.transform.SetAsLastSibling(); // Setup the component return(clonedObject.GetComponent <LanguageToggle>()); }
private void SetupToggle(LanguageToggle clonedToggle, string languageName, StringBuilder nameBuilder) { // Setup the toggle clonedToggle.Language = languageName; clonedToggle.OnChecked += LanguageCheckbox_OnChecked; // Changing the name of the toggles nameBuilder.Clear(); nameBuilder.Append(clonedToggle.Language); nameBuilder.Append(appendName); clonedToggle.name = nameBuilder.ToString(); // Add the toggle to the dictionary languageToControlMap.Add(languageName, clonedToggle); // Check the language, and whether it's current or not clonedToggle.Checkbox.isOn = (languageName == Translations.CurrentLanguage); }