SectionGuiController CreateSectionIndicator()
    {
        GameObject indicatorObject = Instantiate(sectionIndicatorPrefab);

        indicatorObject.transform.SetParent(sectionIndicatorParent.transform);
        indicatorObject.transform.localScale = new Vector3(1, 1, 1);

        SectionGuiController indicator = indicatorObject.GetComponent <SectionGuiController>();

        indicator.handle = this;
        indicatorObject.SetActive(false);

        return(indicator);
    }
예제 #2
0
    void Update()
    {
        ChartEditor editor = ChartEditor.Instance;

        halfHeight       = rectTransform.rect.height / 2.0f;
        scaledHalfHeight = halfHeight * transform.lossyScale.y;

        int newPercentageValue = (int)(handlePosRound * 100);

        if (previousPercentageValue != newPercentageValue)
        {
            UpdatePercentageText(newPercentageValue);
        }

        bool update = (!ReferenceEquals(prevSong, editor.currentSong) || prevSongLength != editor.currentSong.length ||
                       previousScreenSize.x != Screen.width || previousScreenSize.y != Screen.height ||
                       prevRes.height != Screen.currentResolution.height ||
                       prevRes.width != Screen.currentResolution.width || prevRes.refreshRate != Screen.currentResolution.refreshRate);

        // Check if indicator pools need to be extended

        while (sectionIndicatorPool.Length < editor.currentSong.sections.Count)
        {
            SectionGuiController[] controllers = new SectionGuiController[sectionIndicatorPool.Length + POOL_EXTEND_SIZE];
            System.Array.Copy(sectionIndicatorPool, controllers, sectionIndicatorPool.Length);

            for (int i = sectionIndicatorPool.Length; i < controllers.Length; ++i)
            {
                controllers[i] = CreateSectionIndicator(i);
            }

            sectionIndicatorPool = controllers;
        }

        while (starpowerIndicatorPool.Length < editor.currentChart.starPower.Count)
        {
            StarpowerGUIController[] controllers = new StarpowerGUIController[starpowerIndicatorPool.Length + POOL_EXTEND_SIZE];
            System.Array.Copy(starpowerIndicatorPool, controllers, starpowerIndicatorPool.Length);

            for (int i = starpowerIndicatorPool.Length; i < controllers.Length; ++i)
            {
                controllers[i] = CreateSPIndicator(i);
            }

            starpowerIndicatorPool = controllers;
        }

        // Set the sections
        if (update || editor.currentSong.sections.Count != prevSectionLength || forceFullRepaint)
        {
            StartCoroutine(UpdateSectionIndicator());
        }

        // Set the sp
        if (update || editor.currentChart.starPower.Count != prevSPLength || forceFullRepaint)
        {
            StartCoroutine(UpdateStarpowerIndicators());
        }

        prevSong             = editor.currentSong;
        prevSongLength       = editor.currentSong.length;
        prevSPLength         = editor.currentChart.starPower.Count;
        prevSectionLength    = editor.currentSong.sections.Count;
        previousScreenSize.x = Screen.width;
        previousScreenSize.y = Screen.height;
        prevRes = Screen.currentResolution;

        forceFullRepaint = false;
    }