private void OnEnable() { _target = Selection.activeObject; var assetPath = AssetDatabase.GetAssetPath(_target); _targetGuid = AssetDatabase.AssetPathToGUID(assetPath); _foldOutStates.Clear(); foreach (var type in SearchTypes) { _foldOutStates[type.Name] = false; } var sourceMapping = PrefabTracker.FindTypeFiles(SearchTypes); var sourceCount = sourceMapping.Sum(q => q.Value.Count); _resultMapping = new Dictionary <string, List <Object> >(); int count = 0; EditorUtility.DisplayProgressBar("Searching..", $"0/{sourceCount}", 0); foreach (var pair in sourceMapping) { var mapping = pair.Value; var list = new List <Object>(); _resultMapping[pair.Key] = list; while (mapping.Count != 0) { string line; bool foundGuid = false; var file = mapping.Dequeue(); using (var reader = new StreamReader(file)) { while ((line = reader.ReadLine()) != null) { if (!line.Contains(_targetGuid)) { continue; } foundGuid = true; break; } } if (foundGuid) { list.Add(AssetDatabase.LoadAssetAtPath <Object>(file)); } count++; EditorUtility.DisplayProgressBar( "Searching..", $"{count}/{sourceCount}", (float)count / sourceCount); Thread.Sleep(10); } } EditorUtility.ClearProgressBar(); }
protected void Start() { PrefabTracker tracker = GetComponent <PrefabTracker>(); if (tracker) { _poolType = tracker.getPath(); } }
private void CreatePoolFromResources(string resourcesPath, int poolSize, System.Action <GameObject> method) { Object[] resourcesPrefabs = ResourceLoader.LoadGameObjectFromPath(resourcesPath); foreach (Object prefab in resourcesPrefabs) { if (!prefab) { throw new System.Exception("Resource loading has failed!"); } string poolName = prefab.name; //_poolTypes.Add(poolName); // A callback to attach the pool name to the instantiated object. method = (go) => { PrefabTracker tracker = go.AddComponent <PrefabTracker>(); tracker.SetPrefabName(poolName); }; ObjectPoolManager.Instance.CreatePool(poolName, GetPool((GameObject)prefab, poolSize, method)); } }