Ejemplo n.º 1
0
        public void ExportScript(Type tp, bool stubOnly, bool overwrite)
        {
            string key = tp.Name;

            if (exportedScripts.Contains(key))
            {
                return;
            }
            try
            {
                string scriptPath = Path.Combine(ScriptDir, key + ".cs");
                if (!overwrite && File.Exists(scriptPath))
                {
                    return;
                }
                if (scripts.ContainsKey(key))
                {
                    ScriptTranslator translator = new ScriptTranslator(File.ReadAllLines(scripts[key]));
                    if (stubOnly)
                    {
                        translator.CreateStub();
                    }
                    else
                    {
                        translator.Translate();
                    }
                    File.WriteAllText(scriptPath, translator.ToString());
                }
            }
            catch (Exception ex)
            {
                Debug.LogError(key + " export exception: " + ex.Message);
            }
            finally
            {
                exportedScripts.Add(key);
            }
        }
Ejemplo n.º 2
0
 public void ExportScript(Type tp, bool stubOnly, bool overwrite)
 {
     string key = tp.Name;
     if (exportedScripts.Contains(key)) return;
     try
     {
         string scriptPath = Path.Combine(ScriptDir, key + ".cs");
         if (!overwrite && File.Exists(scriptPath))
         {
             return;
         }
         if (scripts.ContainsKey(key))
         {
             ScriptTranslator translator = new ScriptTranslator(File.ReadAllLines(scripts[key]));
             if (stubOnly)
             {
                 translator.CreateStub();
             }
             else
             {
                 translator.Translate();
             }
             File.WriteAllText(scriptPath, translator.ToString());
         }
     }
     catch (Exception ex)
     {
         Debug.LogError(key + " export exception: " + ex.Message);
     }
     finally
     {
         exportedScripts.Add(key);
     }
 }
Ejemplo n.º 3
0
 private void TranslateScriptFile(string scriptFile)
 {
     try
     {
         string scriptText = File.ReadAllText(scriptFile);
         string[] textLines = scriptText.Split('\n');
         PressPlay.FFWD.Exporter.ScriptTranslator trans = new ScriptTranslator(textLines);
         trans.Translate();
         string newText = trans.ToString();
         string newPath = scriptFile.Replace(Path.Combine(Application.dataPath, config.unityScriptDir), Path.Combine(xnaBaseDir, config.xnaAssets.ScriptDir));
         if (!Directory.Exists(Path.GetDirectoryName(newPath)))
         {
             Directory.CreateDirectory(Path.GetDirectoryName(newPath));
         }
         File.WriteAllText(newPath, newText);
     }
     catch (Exception ex)
     {
         Debug.LogError("Error when converting script " + Path.GetFileName(scriptFile) + ": " + ex.Message);
     }
 }