示例#1
0
 static public bool Load(string xmlFileName, ref DvpOptions rOptions)
 {
     try
     {
         XmlSerializer        xmlReader  = new XmlSerializer(typeof(DvpOptions));
         System.IO.TextReader textReader = new System.IO.StreamReader(xmlFileName);
         rOptions = (DvpOptions)xmlReader.Deserialize(textReader);
         textReader.Close();
         return(true);
     }
     catch (System.Exception e)
     {
         UnityEngine.Debug.LogError("Error: " + e.Message);
         return(false);
     }
 }
示例#2
0
    void OnEnable()
    {
        if (!SystemInfo.graphicsDeviceVersion.StartsWith("OpenGL"))
        {
            enabled = false;
            return;
        }

        sdiEnabled  = false;
        IOCoroutine = SdiIOCoroutine();

#if !UNITY_EDITOR
        if (!DvpOptions.Load(DvpOptions.ConfigFileName, ref options))
        {
            DvpOptions.Save(DvpOptions.ConfigFileName, options);
        }
#endif

        StartCoroutine(IOCoroutine);
    }
示例#3
0
    static public bool Save(string xmlFileName, DvpOptions options)
    {
        try
        {
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(xmlFileName);
            if (!fileInfo.Exists)
            {
                System.IO.Directory.CreateDirectory(fileInfo.Directory.FullName);
            }

            XmlSerializer        serializer = new XmlSerializer(typeof(DvpOptions));
            System.IO.TextWriter textWriter = new System.IO.StreamWriter(xmlFileName);
            serializer.Serialize(textWriter, options);
            textWriter.Close();
            return(true);
        }
        catch (System.Exception e)
        {
            UnityEngine.Debug.LogError("Error: " + e.Message);
            return(false);
        }
    }