private WebTemplate Load(string path) { if (!Directory.Exists(path)) { return(null); } WebTemplate template = new WebTemplate(); string[] splitPath = path.Split(new char[] { '/', '\\' }); template.m_Name = splitPath[splitPath.Length - 1]; if (splitPath.Length > 3 && splitPath[splitPath.Length - 3].Equals("Assets")) { template.m_Path = "PROJECT:" + template.m_Name; } else { template.m_Path = "APPLICATION:" + template.m_Name; } string thumbnailPath = Path.Combine(path, "thumbnail.png"); if (File.Exists(thumbnailPath)) { template.m_Thumbnail = new Texture2D(2, 2); template.m_Thumbnail.LoadImage(File.ReadAllBytes(thumbnailPath)); } template.m_CustomKeys = GetCustomKeys(path); return(template); }
private WebTemplate Load(string path) { if (!Directory.Exists(path) || Directory.GetFiles(path, "index.*").Length < 1) { return((WebTemplate)null); } string[] strArray = path.Split(new char[2] { '/', '\\' }); WebTemplate webTemplate = new WebTemplate(); webTemplate.m_Name = strArray[strArray.Length - 1]; webTemplate.m_Path = strArray.Length <= 3 || !strArray[strArray.Length - 3].Equals("Assets") ? "APPLICATION:" + webTemplate.m_Name : "PROJECT:" + webTemplate.m_Name; string[] files = Directory.GetFiles(path, "thumbnail.*"); if (files.Length > 0) { webTemplate.m_Thumbnail = new Texture2D(2, 2); webTemplate.m_Thumbnail.LoadImage(File.ReadAllBytes(files[0])); } List <string> stringList = new List <string>(); foreach (Capture match in new Regex("\\%UNITY_CUSTOM_([A-Z_]+)\\%").Matches(File.ReadAllText(Directory.GetFiles(path, "index.*")[0]))) { string str1 = match.Value.Substring("%UNITY_CUSTOM_".Length); string str2 = str1.Substring(0, str1.Length - 1); if (!stringList.Contains(str2)) { stringList.Add(str2); } } webTemplate.m_CustomKeys = stringList.ToArray(); return(webTemplate); }
private WebTemplate Load(string path) { if (!Directory.Exists(path) || Directory.GetFiles(path, "index.*").Length < 1) return (WebTemplate) null; string[] strArray = path.Split(new char[2]{ '/', '\\' }); WebTemplate webTemplate = new WebTemplate(); webTemplate.m_Name = strArray[strArray.Length - 1]; webTemplate.m_Path = strArray.Length <= 3 || !strArray[strArray.Length - 3].Equals("Assets") ? "APPLICATION:" + webTemplate.m_Name : "PROJECT:" + webTemplate.m_Name; string[] files = Directory.GetFiles(path, "thumbnail.*"); if (files.Length > 0) { webTemplate.m_Thumbnail = new Texture2D(2, 2); webTemplate.m_Thumbnail.LoadImage(File.ReadAllBytes(files[0])); } List<string> stringList = new List<string>(); foreach (Capture match in new Regex("\\%UNITY_CUSTOM_([A-Z_]+)\\%").Matches(File.ReadAllText(Directory.GetFiles(path, "index.*")[0]))) { string str1 = match.Value.Substring("%UNITY_CUSTOM_".Length); string str2 = str1.Substring(0, str1.Length - 1); if (!stringList.Contains(str2)) stringList.Add(str2); } webTemplate.m_CustomKeys = stringList.ToArray(); return webTemplate; }
private WebTemplate Load(string path) { if (!Directory.Exists(path)) { return(null); } WebTemplate template = new WebTemplate(); string[] splitPath = path.Split(new char[] { '/', '\\' }); template.m_Name = splitPath[splitPath.Length - 1]; if (splitPath.Length > 3 && splitPath[splitPath.Length - 3].Equals("Assets")) { template.m_Path = "PROJECT:" + template.m_Name; } else { template.m_Path = "APPLICATION:" + template.m_Name; } string thumbnailPath = Path.Combine(path, "thumbnail.png"); if (File.Exists(thumbnailPath)) { template.m_Thumbnail = new Texture2D(2, 2); template.m_Thumbnail.LoadImage(File.ReadAllBytes(thumbnailPath)); } Regex preprocessedFilenameRegex = new Regex("\\.(html|php|css|js|json)$"); Regex preprocessedBlockRegex = new Regex("((^|\\n)#if [^\\n]+(\\n|$))|({{{([^}]|}(?!}))+}}})"); Regex customKeyRegex = new Regex("(?<=[^0-9a-zA-Z_$]UNITY_CUSTOM_)[A-Z_]+(?=[^0-9a-zA-Z_$])"); List <string> customKeys = new List <string>(); foreach (var file in FileUtil.GetAllFilesRecursive(path)) { if (preprocessedFilenameRegex.IsMatch(FileUtil.UnityGetFileName(file))) { MatchCollection preprocessedBlockMatches = preprocessedBlockRegex.Matches(File.ReadAllText(file)); foreach (Match preprocessedBlockMatch in preprocessedBlockMatches) { MatchCollection customKeysMatches = customKeyRegex.Matches(preprocessedBlockMatch.Value); foreach (Match customKeysMatch in customKeysMatches) { if (!customKeys.Contains(customKeysMatch.Value)) { customKeys.Add(customKeysMatch.Value); } } } } } template.m_CustomKeys = customKeys.ToArray(); return(template); }
private WebTemplate Load(string path) { if (!Directory.Exists(path) || (Directory.GetFiles(path, "index.*").Length < 1)) { return(null); } char[] separator = new char[] { '/', '\\' }; string[] strArray = path.Split(separator); WebTemplate template = new WebTemplate { m_Name = strArray[strArray.Length - 1] }; if ((strArray.Length > 3) && strArray[strArray.Length - 3].Equals("Assets")) { template.m_Path = "PROJECT:" + template.m_Name; } else { template.m_Path = "APPLICATION:" + template.m_Name; } string[] files = Directory.GetFiles(path, "thumbnail.*"); if (files.Length > 0) { template.m_Thumbnail = new Texture2D(2, 2); template.m_Thumbnail.LoadImage(File.ReadAllBytes(files[0])); } List <string> list = new List <string>(); Regex regex = new Regex(@"\%UNITY_CUSTOM_([A-Z_]+)\%"); IEnumerator enumerator = regex.Matches(File.ReadAllText(Directory.GetFiles(path, "index.*")[0])).GetEnumerator(); try { while (enumerator.MoveNext()) { Match current = (Match)enumerator.Current; string item = current.Value.Substring("%UNITY_CUSTOM_".Length); item = item.Substring(0, item.Length - 1); if (!list.Contains(item)) { list.Add(item); } } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable == null) { } disposable.Dispose(); } template.m_CustomKeys = list.ToArray(); return(template); }
private List <WebTemplate> ListTemplates(string path) { List <WebTemplate> webTemplateList = new List <WebTemplate>(); foreach (string directory in Directory.GetDirectories(path)) { WebTemplate webTemplate = this.Load(directory); if (webTemplate != null) { webTemplateList.Add(webTemplate); } } return(webTemplateList); }
private List <WebTemplate> ListTemplates(string path) { List <WebTemplate> list = new List <WebTemplate>(); foreach (string str in Directory.GetDirectories(path)) { WebTemplate item = this.Load(str); if (item != null) { list.Add(item); } } return(list); }
private List <WebTemplate> ListTemplates(string path) { List <WebTemplate> templates = new List <WebTemplate>(); string[] directories = Directory.GetDirectories(path); foreach (string directory in directories) { WebTemplate template = Load(directory); if (template != null) { templates.Add(template); } } return(templates); }
private List <WebTemplate> ListTemplates(string path) { List <WebTemplate> list = new List <WebTemplate>(); string[] directories = Directory.GetDirectories(path); string[] array = directories; for (int i = 0; i < array.Length; i++) { string path2 = array[i]; WebTemplate webTemplate = this.Load(path2); if (webTemplate != null) { list.Add(webTemplate); } } return(list); }
private WebTemplate Load(string path) { if (!Directory.Exists(path) || Directory.GetFiles(path, "index.*").Length < 1) { return(null); } string[] splitPath = path.Split(new char[] { '/', '\\' }); WebTemplate template = new WebTemplate(); template.m_Name = splitPath[splitPath.Length - 1]; if (splitPath.Length > 3 && splitPath[splitPath.Length - 3].Equals("Assets")) { template.m_Path = "PROJECT:" + template.m_Name; } else { template.m_Path = "APPLICATION:" + template.m_Name; } string[] thumbFiles = Directory.GetFiles(path, "thumbnail.*"); if (thumbFiles.Length > 0) { template.m_Thumbnail = new Texture2D(2, 2); template.m_Thumbnail.LoadImage(File.ReadAllBytes(thumbFiles[0])); } List <string> keys = new List <string>(); Regex customKeyFinder = new Regex("\\%UNITY_CUSTOM_([A-Z_]+)\\%"); MatchCollection matches = customKeyFinder.Matches(File.ReadAllText(Directory.GetFiles(path, "index.*")[0])); foreach (Match match in matches) { string name = match.Value.Substring("%UNITY_CUSTOM_".Length); name = name.Substring(0, name.Length - 1); if (!keys.Contains(name)) { keys.Add(name); } } template.m_CustomKeys = keys.ToArray(); return(template); }
private WebTemplate Load(string path) { if (!Directory.Exists(path) || Directory.GetFiles(path, "index.*").Length < 1) { return(null); } string[] array = path.Split(new char[] { '/', '\\' }); WebTemplate webTemplate = new WebTemplate(); webTemplate.m_Name = array[array.Length - 1]; if (array.Length > 3 && array[array.Length - 3].Equals("Assets")) { webTemplate.m_Path = "PROJECT:" + webTemplate.m_Name; } else { webTemplate.m_Path = "APPLICATION:" + webTemplate.m_Name; } string[] files = Directory.GetFiles(path, "thumbnail.*"); if (files.Length > 0) { webTemplate.m_Thumbnail = new Texture2D(2, 2); webTemplate.m_Thumbnail.LoadImage(File.ReadAllBytes(files[0])); } List <string> list = new List <string>(); Regex regex = new Regex("\\%UNITY_CUSTOM_([A-Z_]+)\\%"); MatchCollection matchCollection = regex.Matches(File.ReadAllText(Directory.GetFiles(path, "index.*")[0])); foreach (Match match in matchCollection) { string text = match.Value.Substring("%UNITY_CUSTOM_".Length); text = text.Substring(0, text.Length - 1); if (!list.Contains(text)) { list.Add(text); } } webTemplate.m_CustomKeys = list.ToArray(); return(webTemplate); }
private WebTemplate Load(string path) { if (!Directory.Exists(path) || (Directory.GetFiles(path, "index.*").Length < 1)) { return null; } char[] separator = new char[] { '/', '\\' }; string[] strArray = path.Split(separator); WebTemplate template = new WebTemplate { m_Name = strArray[strArray.Length - 1] }; if ((strArray.Length > 3) && strArray[strArray.Length - 3].Equals("Assets")) { template.m_Path = "PROJECT:" + template.m_Name; } else { template.m_Path = "APPLICATION:" + template.m_Name; } string[] files = Directory.GetFiles(path, "thumbnail.*"); if (files.Length > 0) { template.m_Thumbnail = new Texture2D(2, 2); template.m_Thumbnail.LoadImage(File.ReadAllBytes(files[0])); } List<string> list = new List<string>(); Regex regex = new Regex(@"\%UNITY_CUSTOM_([A-Z_]+)\%"); IEnumerator enumerator = regex.Matches(File.ReadAllText(Directory.GetFiles(path, "index.*")[0])).GetEnumerator(); try { while (enumerator.MoveNext()) { Match current = (Match) enumerator.Current; string item = current.Value.Substring("%UNITY_CUSTOM_".Length); item = item.Substring(0, item.Length - 1); if (!list.Contains(item)) { list.Add(item); } } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable == null) { } disposable.Dispose(); } template.m_CustomKeys = list.ToArray(); return template; }
private WebTemplate Load(string path) { WebTemplate result; if (!Directory.Exists(path) || Directory.GetFiles(path, "index.*").Length < 1) { result = null; } else { string[] array = path.Split(new char[] { '/', '\\' }); WebTemplate webTemplate = new WebTemplate(); webTemplate.m_Name = array[array.Length - 1]; if (array.Length > 3 && array[array.Length - 3].Equals("Assets")) { webTemplate.m_Path = "PROJECT:" + webTemplate.m_Name; } else { webTemplate.m_Path = "APPLICATION:" + webTemplate.m_Name; } string[] files = Directory.GetFiles(path, "thumbnail.*"); if (files.Length > 0) { webTemplate.m_Thumbnail = new Texture2D(2, 2); webTemplate.m_Thumbnail.LoadImage(File.ReadAllBytes(files[0])); } List <string> list = new List <string>(); Regex regex = new Regex("\\%UNITY_CUSTOM_([A-Z_]+)\\%"); MatchCollection matchCollection = regex.Matches(File.ReadAllText(Directory.GetFiles(path, "index.*")[0])); IEnumerator enumerator = matchCollection.GetEnumerator(); try { while (enumerator.MoveNext()) { Match match = (Match)enumerator.Current; string text = match.Value.Substring("%UNITY_CUSTOM_".Length); text = text.Substring(0, text.Length - 1); if (!list.Contains(text)) { list.Add(text); } } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } webTemplate.m_CustomKeys = list.ToArray(); result = webTemplate; } return(result); }
private WebTemplate Load(string path) { if (!Directory.Exists(path) || Directory.GetFiles(path, "index.*").Length < 1) { return null; } string[] array = path.Split(new char[] { Path.DirectorySeparatorChar }); WebTemplate webTemplate = new WebTemplate(); webTemplate.m_Name = array[array.Length - 1]; if (array.Length > 3 && array[array.Length - 3].Equals("Assets")) { webTemplate.m_Path = "PROJECT:" + webTemplate.m_Name; } else { webTemplate.m_Path = "APPLICATION:" + webTemplate.m_Name; } string[] files = Directory.GetFiles(path, "thumbnail.*"); if (files.Length > 0) { webTemplate.m_Thumbnail = new Texture2D(2, 2); webTemplate.m_Thumbnail.LoadImage(File.ReadAllBytes(files[0])); } List<string> list = new List<string>(); Regex regex = new Regex("\\%UNITY_CUSTOM_([A-Z_]+)\\%"); MatchCollection matchCollection = regex.Matches(File.ReadAllText(Directory.GetFiles(path, "index.*")[0])); foreach (Match match in matchCollection) { string text = match.Value.Substring("%UNITY_CUSTOM_".Length); text = text.Substring(0, text.Length - 1); if (!list.Contains(text)) { list.Add(text); } } webTemplate.m_CustomKeys = list.ToArray(); return webTemplate; }