Ejemplo n.º 1
0
        private void DisplayResponses(List <string> _responses, bool allowEdit)
        {
            CleanupCreatedResponses();
            int   maxPerColumn = 9;
            float offset       = 0;

            m_createdParentSet = Instantiate(ParentPrefab);
            m_createdParentSet.transform.parent        = m_responsesParentTransform;
            m_createdParentSet.transform.localPosition = Vector3.zero;
            m_createdParentSet.transform.localRotation = Quaternion.identity;
            int  index = -1;
            bool hasReachedSecondColumn = false;

            foreach (var response in _responses)
            {
                index++;
                if (index == maxPerColumn)
                {
                    hasReachedSecondColumn = true;
                    offset = 0;
                }

                var child = Instantiate(ChildInteractivePrefab);
                child.AllowSelection          = allowEdit;
                child.AllowDeselect           = false;
                child.transform.parent        = m_createdParentSet.transform;
                child.transform.localPosition = new Vector3(hasReachedSecondColumn ? 0.35f : 0, -offset, 0);
                child.transform.localRotation = Quaternion.identity;
                m_createdParentSet.Interactives.Add(child);


                int    maxCharPerRowElement  = 25;
                var    labelTheme            = child.GetComponent <LabelTheme>();
                string responseToBeDisplayed = _responses.Count > maxPerColumn?GenerateMultilineString(response, maxCharPerRowElement) : response;

                labelTheme.Default  = responseToBeDisplayed;
                labelTheme.Selected = responseToBeDisplayed;

                offset += 0.057f;

                m_createdResponses.Add(child);
            }

            m_createdParentSet.gameObject.SetActive(true);

            Question currentQuestion = Dictionary[m_currentQuestionID];

            m_createdParentSet.SelectedIndices = currentQuestion.SelectedResponse == -1 ? new List <int> {
            } : new List <int> {
                currentQuestion.SelectedResponse
            };
            if (allowEdit)
            {
                m_createdParentSet.OnSelectionEvents.AddListener(new UnityEngine.Events.UnityAction(() =>
                {
                    currentQuestion.SelectedResponse = m_createdParentSet.SelectedIndices.Count != 0 ? m_createdParentSet.SelectedIndices[0] : -1;
                }));
            }
        }
Ejemplo n.º 2
0
    // Use this for initialization
    private void Start()
    {
        game = GameManager.Instance;
        game.OnDREStageChange += OnDREStageChange;

        interactiveSet     = GetComponent <InteractiveSet>();
        interactiveToggles = interactiveSet.Interactives;
    }
        /// <summary>
        /// The user pressed the send button.
        /// If something is selected it will be logged.
        /// </summary>
        public void SendNote()
        {
            InteractiveSet interactiveSet = TargetGroup.GetInteractiveSet();

            foreach (int index in interactiveSet.SelectedIndices)
            {
                Debug.Log("Send new note: " + TargetGroup.Titles[index].Replace("\n", " "));
            }
            if (interactiveSet.SelectedIndices.Count == 0)
            {
                Debug.Log("Please select a note.");
            }
        }