C# 如果装置2D C中未触发条件#

C# 如果装置2D C中未触发条件#,c#,unity3d,C#,Unity3d,我用这段代码根据playerPrefs中的主题更改颜色,当我调试.Log()时,该主题会正确显示在控制台中,但不会触发ifs。在红色的条件下,我放置了两个日志,但没有一个被触发 出于某种原因使用UnityEngine;代码框中不显示使用UnityEngine.UI的代码,也不显示final}。蓝色也有一个条件,类似于我在这里提到的红色,以增加可读性 使用UnityEngine; 使用UnityEngine.UI public class LoadThemesHome : MonoBehaviou

我用这段代码根据playerPrefs中的主题更改颜色,当我调试.Log()时,该主题会正确显示在控制台中,但不会触发ifs。在红色的条件下,我放置了两个日志,但没有一个被触发

出于某种原因使用UnityEngine;代码框中不显示使用UnityEngine.UI的代码,也不显示final}。蓝色也有一个条件,类似于我在这里提到的红色,以增加可读性

使用UnityEngine; 使用UnityEngine.UI

public class LoadThemesHome : MonoBehaviour
{

public string theme;

//ALL VARS

public Camera cameraMain;

public Image top;
public Text topText;

public Image timerButton;
public Text timerText;

public Image settingsButton;
public Text settingsText;

public Text info;

public Image bottom;
public Text bottomText;

void Start()
{
    if (PlayerPrefs.GetString("theme") != null)
    {
        theme = PlayerPrefs.GetString("theme");
    }
    else
    {
        theme = "black";
        PlayerPrefs.SetString("theme", theme);
    }
}

private void Update()
{
    Debug.Log(theme);

    if (theme == "Black")
    {
        //cameraMain.backgroundColor = new Color(70, 70, 70);

        top.color = new Color(0, 0, 0);
        topText.color = new Color(255, 255, 255);

        timerButton.color = new Color(255, 255, 255);
        timerText.color = new Color(30, 30, 30);

        settingsButton.color = new Color(255, 255, 255);
        settingsText.color = new Color(30, 30, 30);

        info.color = new Color(255, 255, 255);

        bottom.color = new Color(0, 0, 0);
        bottomText.color = new Color(255, 255, 255);
    }
    
    else if (theme == "Red")
    {
        Debug.Log("Start");

        //cameraMain.backgroundColor = new Color(0, 0, 185);

        top.color = new Color(100, 0, 0);
        topText.color = new Color(255, 255, 255);

        timerButton.color = new Color(255, 255, 255);
        timerText.color = new Color(125, 0, 0);

        settingsButton.color = new Color(255, 255, 255);
        settingsText.color = new Color(125, 0, 0);

        info.color = new Color(255, 255, 255);

        bottom.color = new Color(0, 0, 0);
        bottomText.color = new Color(255, 255, 255);

        Debug.Log("Done");
    }
}

}`试着用所有较低的字符来写这些

例如,写“红色”而不是“红色”