Пример #1
0
    // Use this for initialization
    void Start()
    {
        Button reset = GetComponentInChildren <Button> ();

        reset.onClick.AddListener(OnResetClick);

        QuizGroupHelp quizGroup = GetComponentInChildren <QuizGroupHelp> ();

        InputField[]      inputs = GetComponentsInChildren <InputField> ();
        List <InputField> cache  = new List <InputField> ();

        foreach (var i in inputs)
        {
            if (string.CompareOrdinal(i.name, "InputField-V") == 0)                // it needs a special validator.
            {
                QuizHelp help = i.GetComponent <QuizHelp> ();
                if (help != null)
                {
                    help.Validator = NodeSetValidator;
                }
                continue;
            }

            // by matching names, find a pair of graph nodes for one edge.
            if (i.name.StartsWith("InputField-E"))
            {
                int        pos   = "InputField-E".Length;
                char       group = i.name [pos];
                InputField match = cache.Find(input => input.name[pos] == group);
                if (match == null)
                {
                    cache.Add(i);
                }
                else
                {
                    char order1 = i.name [pos + 1];
                    char order2 = match.name [pos + 1];
                    if (order1 < order2)
                    {
                        quizGroup.AddEdgeInput(i, match);
                    }
                    else
                    {
                        quizGroup.AddEdgeInput(match, i);
                    }
                    cache.Remove(match);
                }
                continue;
            }
        }
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        Button[] buttons = GetComponentsInChildren <Button> ();
        foreach (var btn in buttons)
        {
            if (btn.name.CompareTo("btn_reset") == 0)
            {
                btn.onClick.AddListener(OnResetClick);
            }
            else if (btn.name.CompareTo("btn_commit") == 0)
            {
                btn.onClick.AddListener(OnCommitClick);
            }
        }

        m_GroupHelp = Parent.GetComponentInChildren <QuizGroupHelp> ();
    }