private static void PathFind(Base2 scr, FieldInfo pf) { FindTransform atr = (FindTransform)pf.GetCustomAttributes(true).FirstOrDefault(a => a is FindTransform); if (atr != null) { string name = (atr.name == null) ? pf.Name : atr.name; try { GameObject g = atr.scene ? GameObject.Find(name).gameObject : scr.transform.GetTransforms().FirstOrDefault(a => a.name == name).gameObject; if (g == null) { throw new Exception(); } if (pf.FieldType == typeof(GameObject)) { pf.SetValue(scr, g); } else { pf.SetValue(scr, g.GetComponent(pf.FieldType)); } } catch { Debug.Log("cound not find path " + scr.name + "+" + name); } } }
private static void FindTransform(Base scr, FieldInfo pf) { FindTransform atr = (FindTransform)pf.GetCustomAttributes(true).FirstOrDefault(a => a is FindTransform); if (atr != null) { string name = (atr.name == null) ? pf.Name : atr.name; Transform g; try { g = atr.self ? scr.transform : scr.transform.GetTransforms().FirstOrDefault(a => a.name == name); //if (g == null) g = GameObject.Find(name).transform; if (g == null) { throw new Exception(); } if (pf.FieldType == typeof(GameObject)) { pf.SetValue(scr, g.gameObject); } else { var c = g.GetComponent(pf.FieldType); if (c == null) { throw new Exception(); } pf.SetValue(scr, c); } } catch { Debug.Log(scr.name + " cound not find path " + scr.name + "+" + name); } } }
internal FileSystemEnumerable(string directory, FindTransform transform, EnumerationOptions?options, bool isNormalized) { _directory = directory ?? throw new ArgumentNullException(nameof(directory)); _transform = transform ?? throw new ArgumentNullException(nameof(transform)); _options = options ?? EnumerationOptions.Default; // We need to create the enumerator up front to ensure that we throw I/O exceptions for // the root directory on creation of the enumerable. _enumerator = new DelegateEnumerator(this, isNormalized); }
private IEnumerable <string> EnumerateFullFileSystemPaths(string path, string searchPattern, bool includeFiles, bool includeDirectories) { FindPredicate predicate = (ref ReadOnlySpan <char> fileName) => { return(FileMatcher.IsAllFilesWildcard(searchPattern) || FileMatcher.IsMatch(fileName, searchPattern)); }; FindTransform <string> transform = (ref ReadOnlySpan <char> fileName) => Path.Join(path.AsSpan(), fileName); IEnumerable <string> directories = includeDirectories ? _directoryCache.EnumerateDirectories(path, searchPattern, predicate, transform) : Enumerable.Empty <string>(); IEnumerable <string> files = includeFiles ? _directoryCache.EnumerateFiles(path, searchPattern, predicate, transform) : Enumerable.Empty <string>(); return(Enumerable.Concat(directories, files)); }
public FileSystemEnumerable(string directory, FindTransform transform, EnumerationOptions?options = null) : this(directory, transform, options, isNormalized : false) { }
public FileSystemEnumerable(string directory, FindTransform transform, EnumerationOptions options = null) { }