public static Entry[] GetFields(object obj, bool seen) { var type = obj.GetType(); var accessors = GetAccessors(type); Debug.Log("[Available Properties]"); if (accessors != null && accessors[1] != null) { Array.ForEach(accessors[1], (x) => { if (x != null && x.Info != null) { Debug.LogFormat("{0}", x.Info.Name); } }); } Debug.Log("[/Available Properties]"); return((from a in accessors[seen ? 1 : 3] let value = a.Get(obj) select new Entry() { FieldInfo = a.FieldInfo, MustHaveName = true, Value = value, IsStatic = a.IsStatic }).ToArray()); }
public void WaitUntilClassIsAvailable(string type) { Debug.LogFormat("Waiting for '{0}' class.", type); ThreadSafeEditor tse = new ThreadSafeEditor(); Thread th = new Thread(() => { tse.Message("echo prueba xd", "echo hola"); int secs = 30; bool av = false; while (--secs > 0) { av = Type.GetType(type) != null; if (av) { break; } Thread.Sleep(1000); } if (av) { fin(); } }); th.Start(); }
public static void AttachResource(string name, string contents) { Debug.LogFormat("Attaching {0} file, with content:\n\n{1}", name, contents); string path = Path.Combine(Application.dataPath, "Lerp2API/AttachedScripts/"), file = Path.Combine(path, name); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (!File.Exists(file) || File.ReadAllText(file) != contents) { File.WriteAllText(file, contents); } }
internal static void DoUpdate(string newerVersion) { string depPath = Path.GetDirectoryName(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)), editorPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string[] deps = new string[] { Path.Combine(depPath, "Lerp2API.dll"), Path.Combine(depPath, "Lerp2API.pdb"), Path.Combine(depPath, "Lerp2API.xml"), Path.Combine(editorPath, "Lerp2APIEditor.dll"), Path.Combine(editorPath, "Lerp2APIEditor.pdb"), Path.Combine(editorPath, "Lerp2APIEditor.xml"), Path.Combine(editorPath, "Lerp2API.version") }; WWW[] wwws = updateUrls.GetWWW(); if (!deps.All(x => File.Exists(x))) { Debug.LogErrorFormat("Some Library files doesn't exist, aborting update mission!\nDownload them manually from {0}, and put them in '{1}' folder.", @"<a href=""https://github.com/Lerp2Dev/Lerp2API/tree/master/Build"">here</a>", depPath); } else { wh = new WWWHandler(); wh.Add(wwws); wh.Start <WWW[]>(false, (x) => { int v = 0; try { for (int i = 0; i < x.Length; ++i) { File.Delete(deps[i]); v = i; File.WriteAllBytes(deps[i], x[i].bytes); } } catch (Exception ex) { Debug.LogFormat("Oh guy! You are so fast, {0} has not been downloaded!\n{1}\n{2}", x[v].url, ex.Message, ex.StackTrace); } Debug.LogFormat("Update to '{0}' successfully done!", newerVersion); AssetDatabase.Refresh(); }); } }