예제 #1
0
        public LerpedThread(string name, FSWParams pars)
        {
            if (typeof(T) == typeof(FileSystemWatcher))
            {
                try
                {
                    FileSystemWatcher watcher = new FileSystemWatcher(pars.path, pars.filter);

                    watcher.NotifyFilter          = pars.notifiers;
                    watcher.IncludeSubdirectories = pars.includeSubfolders;

                    watcher.Changed += OnChanged;
                    watcher.Created += OnChanged;
                    watcher.Deleted += OnChanged;
                    watcher.Renamed += OnRenamed;

                    ApplyChanges(watcher);
                }
                catch (Exception ex)
                {
                    Debug.LogErrorFormat("Folder not found!\n{0}\n{1}", pars.path, ex);
                }
            }
        }
예제 #2
0
        private static void DownloadEditorFiles()
        {
            if (resourceFiles.Length != repFiles.Length)
            {
                Debug.LogError("Internal error ocurred, Resource Files and Repository Files Array have to had the same length!");
                return;
            }
            bool ae = resourceFiles.All(x => File.Exists(x));

            if (ae)
            {
                return;
            }
            if (!ae && LerpedUpdater.noConnection)
            {
                Debug.LogError("No conection available to download!");
                return;
            }
            for (int i = 0; i < resourceFiles.Length; ++i)
            {
                if (!File.Exists(resourceFiles[i]))
                {
                    string fp = Path.GetDirectoryName(resourceFiles[i]);
                    if (!Directory.Exists(fp))
                    {
                        Directory.CreateDirectory(fp);
                    }
                    WWW www = new WWW(repFiles[i]);
                    wh = new WWWHandler();
                    wh.Add(www);
                    wh.Start <WWW>(false, (x) => {
                        File.WriteAllBytes(resourceFiles[i], x.bytes);
                    });
                }
            }
        }
예제 #3
0
 internal static void SaveCommands()
 {
     JSONHelpers.SerializeToFile(commandPath, myTarget.commandList);
     Debug.Log("Command file saved!");     //Better a dialog, not?
 }
예제 #4
0
        public static string SaveAsAsset <T>(Transporter value, T obj, string name)
        {
            bool emptyName = string.IsNullOrEmpty(name),
                 derivedClass = obj != null && typeof(T).IsSubclassOf(typeof(Object)), alreadyExists = false;
            string n = name, path = "", fpath = "", rpath = "";

            if (emptyName && derivedClass)
            {
                n = ((Object)(object)obj).name;
            }
            else if (emptyName && !derivedClass)
            {
                n = (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds.ToString("F0");
            }
            path          = Path.Combine(Application.streamingAssetsPath, typeof(T).Name);
            fpath         = Path.Combine(path, n + ".asset");
            rpath         = typeof(T).Name + "/" + n + ".asset";
            alreadyExists = File.Exists(fpath);
            if (!alreadyExists)
            {
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                if (value.type.Equals(typeof(string)))
                {
                    if (value.write)
                    {
                        File.WriteAllText(fpath, (string)value.obj);
                    }
                    else
                    {
                        File.AppendAllText(fpath, (string)value.obj + Environment.NewLine);
                    }
                }
                else if (value.type.Equals(typeof(string[])))
                {
                    File.WriteAllLines(fpath, (string[])value.obj);
                }
                else if (value.type.Equals(typeof(byte[])))
                {
                    File.WriteAllBytes(fpath, (byte[])value.obj);
                }
                else
                {
                    throw new Exception("Not recognised type!");
                }
                Debug.Log("Asset saved at " + fpath + "!");
            }
            if (typeof(T).Equals(typeof(GameObject)))
            {
                //if (Application.isPlaying)
                //    Object.Destroy(GameObject.Find(((GameObject)(object)obj).name));
                //else
                if (Application.isEditor)
                {
                    Object.DestroyImmediate(GameObject.Find(((GameObject)(object)obj).name));
                }
            }
            return(rpath);
        }
예제 #5
0
        public static void UpdateDependencies()
        {
            string bPath     = LerpedCore.GetString(buildPath),
                   bePath    = Path.Combine(bPath, "Editor"),
                   bcPath    = Path.Combine(bPath, "Console"),
                   brPath    = Path.Combine(Path.GetDirectoryName(bPath), "Project/Lerp2Raw"),
                   ePath     = LerpedCore.GetString(editorPath),
                   eePath    = Path.Combine(ePath, "Editor"),
                   ecPath    = Path.Combine(ePath, "Console"),
                   batchPath = Path.Combine(Path.GetDirectoryName(bPath), "Compile/compile.bat");

            LerpedCore.SetLong(lastBuildTime, Helpers.LatestModification(Path.GetDirectoryName(bPath)));

            if (!Directory.Exists(bePath))
            {
                Debug.LogError("Editor path couldn't not be found in Build Path!");
                return;
            }
            if (!Directory.Exists(eePath))
            {
                Debug.LogError("Editor path couldn't not be found in Project Path!");
                return;
            }
            if (!File.Exists(batchPath))
            {
                Debug.LogError("Batch compile file couldn't be found, please, download it from Lerp2Dev Repository.");
                return;
            }

            using (var proc = new Process())
            {
                proc.StartInfo.FileName         = batchPath;
                proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(batchPath); //Gracias Elektro: https://foro.elhacker.net/net/processstart_ejecuta_un_batch_y_hace_que_sus_rutas_contiguas_sean_innacesibles-t465478.0.html;msg2109889#msg2109889
                //proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; //This will be hidden when the console of the api compiles itsself and could send messages to Unity?
                proc.Start();
                proc.WaitForExit();
                //int exitCode = proc.ExitCode;
            }

            string[] fbFiles = new string[] { Path.Combine(bPath, "Lerp2API.dll"), Path.Combine(bPath, "Lerp2API.pdb"), Path.Combine(bPath, "Lerp2API.pdb"),
                                              Path.Combine(bePath, "Lerp2APIEditor.dll"), Path.Combine(bePath, "Lerp2APIEditor.pdb"), Path.Combine(bePath, "Lerp2APIEditor.xml"),
                                              Path.Combine(bcPath, "Lerp2Console.exe"), Path.Combine(bcPath, "Lerp2Console.exe.config"), Path.Combine(bcPath, "Lerp2Console.pdb"), Path.Combine(bcPath, "Lerp2Console.xml") },
            feFiles = new string[] { Path.Combine(ePath, "Lerp2API.dll"), Path.Combine(ePath, "Lerp2API.pdb"), Path.Combine(ePath, "Lerp2API.pdb"),
                                     Path.Combine(eePath, "Lerp2APIEditor.dll"), Path.Combine(eePath, "Lerp2APIEditor.pdb"), Path.Combine(eePath, "Lerp2APIEditor.xml"),
                                     Path.Combine(ecPath, "Lerp2Console.exe"), Path.Combine(ecPath, "Lerp2Console.exe.config"), Path.Combine(ecPath, "Lerp2Console.pdb"), Path.Combine(ecPath, "Lerp2Console.xml") };

            //Detect file weight? No, by the moment the Editor makes everything...
            int i = 0;

            try
            {
                foreach (string b in fbFiles)
                {
                    if (File.Exists(b))
                    {
                        File.Copy(b, feFiles[i], true);
                    }
                    else
                    {
                        UnityEngine.Debug.LogErrorFormat("{0} not found!", b);
                    }
                    ++i;
                }
            }
            catch
            {
                Debug.LogError("Something gone wrong copying files at Refreshing Dependencies, cancel all new bugged API Messages to Auto Refresh it dependencies! (If this continues, please, restart Unity, we're looking this issue)");
            }

            //Also, copy Lerp2Raw files...
            foreach (string file in Directory.GetFiles(brPath, "*.cs"))
            {
                File.Copy(file, Path.Combine(Application.dataPath, "Lerp2API/AttachedScripts/" + Path.GetFileName(file)), true);
            }

            AssetDatabase.Refresh();
            int tc = LerpedCore.GetInt(timesCompiled);

            LerpedCore.SetInt(timesCompiled, ++tc);
        }
예제 #6
0
 private void OnDisable()
 {
     UnityEngine.Debug.Log("Unhooking log!");
     Debug.UnhookLog(); //Aquí tengo que guardar todo y mandarle la solicitud a la consola
 }