void Update()
 {
     isSolved = solution == GetColor();
     if (isSolved)
     {
         thisRenderer.SetMainColor(solutionColor);
         thisRenderer.SetColor("_EmissionColor", solutionEmissionColor);
     }
     else
     {
         thisRenderer.SetMainColor(unsolvedColor);
         thisRenderer.SetColor("_EmissionColor", unsolvedEmissionColor);
     }
 }
Exemple #2
0
 void Update()
 {
     if (powered)
     {
         float delta = Mathf.Clamp01(t + Time.deltaTime * turnOnSpeed) - t;
         if (delta > 0)
         {
             t += delta;
             r.SetColor(emissionColorKey, Color.Lerp(startEmission, emissiveColor, t));
         }
     }
     else
     {
         float delta = Mathf.Clamp01(t - Time.deltaTime * turnOnSpeed) - t;
         if (delta < 0)
         {
             t += delta;
             r.SetColor(emissionColorKey, Color.Lerp(startEmission, emissiveColor, t));
         }
     }
 }
    // Use this for initialization
    void Start()
    {
        if (buttonToReactTo == null)
        {
            buttonToReactTo = GetComponent <Button>();
        }
        if (buttonToReactTo == null)
        {
            Debug.LogWarning("No button to react to, disabling color change script", gameObject);
            enabled = false;
            return;
        }

        r = GetComponent <SuperspectiveRenderer>();
        if (r == null)
        {
            r = gameObject.AddComponent <SuperspectiveRenderer>();
        }

        if (useMaterialAsEndColor)
        {
            pressColor    = r.GetMainColor();
            pressEmission = r.GetColor("_EmissionColor");
        }

        if (useMaterialAsStartColor)
        {
            startColor    = r.GetMainColor();
            startEmission = r.GetColor("_EmissionColor");
        }
        else
        {
            r.SetMainColor(startColor);
            r.SetColor("_EmissionColor", startEmission);
        }

        buttonToReactTo.OnButtonPressFinish   += ButtonPressFinish;
        buttonToReactTo.OnButtonUnpressFinish += ButtonUnpressFinish;
    }
    // Update is called once per frame
    void Update()
    {
        Color emissionColor = glowColor * (0.5f * Mathf.Sin(Time.time) + 0.5f);

        thisRenderer.SetColor(emissionColorName, emissionColor);
    }