// Functions public void Start() { // Start the scrollable areas with a maximum distance of 0 titleScrolling.listLength = 0; titleScrolling.UpdateLimits(); Select(-1); }
void Update() { float oldHeight = height; if (oldHeight != height) { this.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, -height / 2); } height = this.GetComponent <RectTransform>().rect.height; scrolling.UpdateLimits(); }
public void UpdateMarkSet() { int count = 0; Deck_Practice.Mark[] details = currentDeck.practiceSessions[selectedPractice].details; foreach (var detail in details) // Update All Cards { if (!detail.instantiated) // Create Title Card. { GameObject newNoteUI = Instantiate(markPrefab, markContainer.transform); markUIList.Add(newNoteUI); details[count].instantiated = true; } if (detail.instantiated)// Set Card Properties { int index = count; float spacing = markPrefab.GetComponent <RectTransform>().rect.height; markUIList[count].GetComponent <RectTransform>().anchoredPosition = new Vector2(0, -spacing / 2 + (count * -spacing)); string question = details[count].question; markUIList[count].transform.Find("Question Text").GetComponent <Text>().text = question; markUIList[count].transform.Find("Question Text").GetComponent <Button>().onClick.RemoveAllListeners(); markUIList[count].transform.Find("Question Text").GetComponent <Button>().onClick.AddListener(() => DetailedText(question)); // Code from https://answers.unity.com/questions/938496/buttononclickaddlistener.html & https://answers.unity.com/questions/1384803/problem-with-onclickaddlistener.html string answer = details[count].answer; markUIList[count].transform.Find("Answer Text").GetComponent <Text>().text = answer; markUIList[count].transform.Find("Answer Text").GetComponent <Button>().onClick.RemoveAllListeners(); markUIList[count].transform.Find("Answer Text").GetComponent <Button>().onClick.AddListener(() => DetailedText(answer)); // Code from https://answers.unity.com/questions/938496/buttononclickaddlistener.html & https://answers.unity.com/questions/1384803/problem-with-onclickaddlistener.html string input = details[count].input; markUIList[count].transform.Find("Input Text").GetComponent <Text>().text = input; markUIList[count].transform.Find("Input Text").GetComponent <Button>().onClick.RemoveAllListeners(); markUIList[count].transform.Find("Input Text").GetComponent <Button>().onClick.AddListener(() => DetailedText(input)); // Code from https://answers.unity.com/questions/938496/buttononclickaddlistener.html & https://answers.unity.com/questions/1384803/problem-with-onclickaddlistener.html if (currentDeck.practiceSessions[selectedPractice].details[count].correct) { markUIList[count].transform.Find("Correct Indicator").gameObject.SetActive(true); markUIList[count].transform.Find("Incorrect Indicator").gameObject.SetActive(false); } else { markUIList[count].transform.Find("Correct Indicator").gameObject.SetActive(false); markUIList[count].transform.Find("Incorrect Indicator").gameObject.SetActive(true); } } count++; } // Update Scroll Limit for Titles markScrolling.listLength = ((count) * markPrefab.GetComponent <RectTransform>().rect.height) + header.rect.height; markScrolling.UpdateLimits(); }
public void Select(int newSelection) // Select note of index "newSelection" from the dataList, assigning all visuals accordingly { if (newSelection == -1) { noteContent.text = ""; noteEditorTitle.text = ""; noteEditorContent.text = ""; noteEditorColourIndex = 0; noteEditorColourIndicator.GetComponent <Image>().color = colourOptions[0].color; if (0 < selection && selection < UIList.Count) { UIList[selection].GetComponent <Toggle>().onValueChanged.RemoveAllListeners(); } // Remove the listeners from the button that will change titleToggleGroup.SetAllTogglesOff(); audioSource.Play(); // Play the click that was removed with the other listeners UpdateList(); // Re-apply the listeners editNote.interactable = false; deleteNote.interactable = false; } else { noteContent.text = dataList[newSelection].content; noteEditorTitle.text = dataList[newSelection].title; noteEditorContent.text = dataList[newSelection].content; noteEditorColourIndex = dataList[newSelection].colour; noteEditorColourIndicator.GetComponent <Image>().color = colourOptions[dataList[newSelection].colour].color; UIList[newSelection].GetComponent <Toggle>().onValueChanged.RemoveAllListeners(); // Remove the listeners titleToggleGroup.SetAllTogglesOff(); UIList[newSelection].GetComponent <Toggle>().isOn = true; audioSource.Play(); // Play the click that was removed with the other listeners UpdateList(); // Re-apply the listeners editNote.interactable = true; deleteNote.interactable = true; } selection = newSelection; contentScrolling.UpdateLimits(); contentScrolling.Reset(); }
// Functions public void Start() { scrolling.listLength = 0; scrolling.UpdateLimits(); }
public void Select(int newSelection) // Select deck of index "newSelection" from the dataList, assigning all visuals accordingly { card_handler.DeleteCardUI(); // Clear Old Card UI First // Must have 3 states to allow for the reminder script to be called with the correct selection. int oldSelection = selection; selection = newSelection; if (newSelection == -1) { description.text = ""; editorTitle.text = ""; editorDescription.text = ""; editorColourIndex = 0; editorColourIndicator.GetComponent <Image>().color = colourOptions[0].color; reminderPeriod.text = ""; if (0 < oldSelection && oldSelection < UIList.Count) { UIList[oldSelection].GetComponent <Toggle>().onValueChanged.RemoveAllListeners(); } // Remove the listeners from the button that will change titleToggleGroup.SetAllTogglesOff(); audioSource.Play(); // Play the click that was removed with the other listeners UpdateList(); // Re-apply the listeners practiceButton.interactable = false; editButton.interactable = false; deleteButton.interactable = false; viewScoreButton.interactable = false; multipleChoiceToggle.interactable = false; multipleChoiceToggle.isOn = false; card_handler.dataList = new List <Card_Handler.Card>(); } else { description.text = dataList[newSelection].description; editorTitle.text = dataList[newSelection].title; editorDescription.text = dataList[newSelection].description; editorColourIndex = dataList[newSelection].colour; editorColourIndicator.GetComponent <Image>().color = colourOptions[dataList[newSelection].colour].color; reminder_handler.ChangeReminder(0); UIList[newSelection].GetComponent <Toggle>().onValueChanged.RemoveAllListeners(); // Remove the listeners titleToggleGroup.SetAllTogglesOff(); UIList[newSelection].GetComponent <Toggle>().isOn = true; audioSource.Play(); // Play the click that was removed with the other listeners UpdateList(); // Re-apply the listeners if (dataList[newSelection].content.Count > 0) { practiceButton.interactable = true; } else { practiceButton.interactable = false; } editButton.interactable = true; deleteButton.interactable = true; if (dataList[newSelection].practiceSessions.Count > 0) { viewScoreButton.interactable = true; } else { viewScoreButton.interactable = false; } if (dataList[newSelection].practiceSessions.Count > 4) { multipleChoiceToggle.interactable = true; } else { multipleChoiceToggle.interactable = false; multipleChoiceToggle.isOn = false; } card_handler.dataList = new List <Card_Handler.Card>(dataList[newSelection].content); } contentScrolling.UpdateLimits(); contentScrolling.Reset(); card_handler.Select(-1); }