Advertisement
PedroArthurr

WeaponCreator

May 7th, 2022
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. using UnityEditor;
  2. using UnityEngine;
  3. using System.IO;
  4.  
  5. public static class WeaponCreator
  6. {
  7. private const string path = "Assets/Scriptable Objects/Weapons";
  8.  
  9. public static void CreateWeaponObject(WeaponSettings settings)
  10. {
  11. WeaponObject weapon = ScriptableObject.CreateInstance<WeaponObject>();
  12. weapon.SetWeaponSettings(settings);
  13.  
  14. if (!Directory.Exists($"{path}/{settings.rarity}"))
  15. Directory.CreateDirectory($"{path}/{settings.rarity}");
  16.  
  17. AssetDatabase.CreateAsset(weapon,
  18. $"{path}/{settings.rarity}/{settings.weaponID} -" +
  19. $" {settings.weaponName} - {settings.type}.asset");
  20.  
  21. AssetDatabase.SaveAssets();
  22. EditorUtility.FocusProjectWindow();
  23. Selection.activeObject = weapon;
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement