void GatherSaveables() { var gos = AssetDatabase.FindAssets("t:GameObject"); var gatheredCount = 0; for (var i = 0; i < gos.Length; i++) { var path = AssetDatabase.GUIDToAssetPath(gos[i]); var go = AssetDatabase.LoadAssetAtPath <GameObject>(path); if (go.GetComponent <Saveable>()) { if (assetMap.Map.Find(mp => mp.Prefab == go) != null) { continue; } var mappedPrefab = new MappedPrefab(); mappedPrefab.Prefab = go; mappedPrefab.UpdateId(); assetMap.Map.Add(mappedPrefab); gatheredCount++; } } Debug.Log("[Pluto Save] Gathered " + gatheredCount + " new saveable prefabs."); if (gatheredCount > 0) { EditorUtility.SetDirty(target); } }
void AddPrefab(AssetMap assetMap, GameObject prefab) { for (var i = 0; i < assetMap.Map.Count; i++) { if (assetMap.Map[i].Prefab == prefab) { Debug.LogWarning("Same prefab already added to the Map"); return; } } var mappedPrefab = new MappedPrefab(); mappedPrefab.Prefab = prefab; mappedPrefab.UpdateId(); assetMap.Map.Add(mappedPrefab); EditorUtility.SetDirty(target); }