Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static List<T> FindAllAssetsOfTypeWithLevel<T>(string folderPath, int targetLevel) where T : ScriptableObject
- {
- List<T> matchingAssets = new List<T>();
- string[] guids = AssetDatabase.FindAssets("t:" + typeof(T).Name, new[] { folderPath });
- foreach (string guid in guids)
- {
- string assetPath = AssetDatabase.GUIDToAssetPath(guid);
- T asset = AssetDatabase.LoadAssetAtPath<T>(assetPath);
- if (asset is WeaponSO weapon && weapon.weaponLevel == targetLevel && !weapon.isBaseSo)
- {
- matchingAssets.Add(asset);
- }
- }
- return matchingAssets;
- }
- #if UNITY_EDITOR
- [ContextMenu("FIND LEVEL 1 WEAPONS")]
- public void FindLevel1Weapons()
- {
- level1Weapons = ScriptableObjectUtils.FindAllAssetsOfTypeWithLevel<WeaponSO>(folderPath, 1);
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment