コード例 #1
0
    public void Set(MistakeButtonSettings newSettings)
    {
        _settings = newSettings;

        numberText.text = settings.mistakeId.ToString();
        nameText.text   = settings.name;
        // TODO
        //icon.image = //////settings.iconPath;

        backgroundImage.color = settings.color;
    }
コード例 #2
0
    private void OnMistakeButtonClicked(MistakeButtonUI sender, MistakeButtonSettings settings)
    {
        float timestamp       = (float)videoPlayer.time;
        bool  wasClickCorrect = WasClickCorrect(settings.mistakeId, timestamp, out int hitIntervalIndex);

        // If any clicks already covered this interval, don't create a new one, just highlight the old one.
        if (wasClickCorrect)
        {
            int clickIndex = mistakeButtonClicks.FindIndex(c =>
                                                           c.wasCorrect &&
                                                           c.mistakeId == settings.mistakeId &&
                                                           c.hitIntervalIndex == hitIntervalIndex
                                                           );
            if (clickIndex != -1)
            {
                mistakeButtonClicks[clickIndex].mistakeMark.Highlight();
                return;
            }
        }

        MistakeMark mark = Instantiate(mistakeMarkPrefab, playbackIndicatorFillAreaTransform);

        mark.SetColor(settings.color);

        float         normalizedTime = (float)(timestamp / videoPlayer.length);
        RectTransform rectTransform  = mark.rectTransform;

        rectTransform.anchorMin = rectTransform.anchorMax = new Vector2(normalizedTime, 1.0f);

        var click = new MistakeButtonClick
        {
            mistakeId        = settings.mistakeId,
            timestamp        = timestamp,
            wasCorrect       = wasClickCorrect,
            hitIntervalIndex = hitIntervalIndex,
            mistakeMark      = mark
        };

        mistakeButtonClicks.Add(click);
        mark.RevealCorrectness(click.wasCorrect);
    }