Ejemplo n.º 1
0
    public void LoadAnaglyph()
    {
        InitMat();
        ResetColors();

        AnaglyphColors colors = null;

        string path = Application.dataPath + "/Resources/colorConfig.json";

        try
        {
            using (FileStream stream = new FileStream(path, FileMode.Open))
            {
                using (StreamReader sr = new StreamReader(stream))
                {
                    colors = JsonConvert.DeserializeObject <AnaglyphColors>(sr.ReadToEnd());
                }
            }
        }
        catch
        {
            colors = null;
        }

        if (colors != null)
        {
            SetRightColor(colors.rightColor);
            SetLeftColor(colors.leftColor);
            SetRightLightness(colors.rightLight);
            SetLeftLightness(colors.leftLight);
            SetEyeOffset(colors.offset);
        }
    }
Ejemplo n.º 2
0
    public void SaveSettings()
    {
        string path = Application.dataPath + "/Resources/colorConfig.json";

        AnaglyphColors colors = new AnaglyphColors(leftCol, rightCol, leftLight, rightLight, eyeOffset);

        StringBuilder colorsSb;

        colorsSb = new StringBuilder(JsonConvert.SerializeObject(colors, Formatting.Indented));

        using (FileStream stream = new FileStream(path, FileMode.Create))
        {
            using (StreamWriter sw = new StreamWriter(stream))
            {
                sw.Write(colorsSb);
            }
        }

        gameObject.SetActive(false);
    }