Example #1
0
 // Makes the screen flash rapidly
 private IEnumerator flashRoutine()
 {
     uint[] pallet = BlockUpdater.currentPallet();
     for (uint j = 0; j < numFlashes; j++)
     {
         Color32 c = flashColors.Dequeue();
         materials[0].SetColor("_Color", Color32.Lerp(Hex2Color(pallet[0]), c, flashLerpRatio));
         flashColors.Enqueue(c);
         yield return(new WaitForSeconds(flashDelay));
     }
     materials[0].SetColor("_Color", Hex2Color(pallet[0]));
 }
Example #2
0
    // Lerps from one color to another in a smooth animation
    private IEnumerator fadeColorPalletRoutine( )
    {
        uint[] pallet = BlockUpdater.currentPallet();

        float h, s, v;

        Color.RGBToHSV(Hex2Color(pallet[0]), out h, out s, out v);

        Color32 fontColor = Color.HSVToRGB(h, s * 3, v * 3);

        // Save Old Colors for Lerp
        Color32[] oldColors = new Color32[materials.Length];
        for (int i = 0; i < oldColors.Length; i++)
        {
            oldColors[i] = materials[i].color;
        }
        Color32 oldFontColor = uiFontPrefab.fontSharedMaterial.GetColor(ShaderUtilities.ID_FaceColor);

        // Slowly transition
        float lerp = 0;

        while (lerp <= 1)
        {
            uiFontPrefab.fontSharedMaterial.SetColor(ShaderUtilities.ID_FaceColor, Color32.Lerp(oldFontColor, fontColor, lerp));
            uiFontPrefab.fontSharedMaterial.SetColor(ShaderUtilities.ID_OutlineColor, Color32.Lerp(oldFontColor, fontColor, lerp));
            for (int i = 0; i < materials.Length; i++)
            {
                materials[i].SetColor("_Color", Color32.Lerp(oldColors[i], Hex2Color(pallet[i]), lerp));
            }

            lerp += dLerpRatio;
            yield return(new WaitForSeconds(colorTransitionDelay));
        }
        //

        BlockUpdater.updateColors();
    }