ItemUtil.cs 736 B

123456789101112131415161718192021222324
  1. using GadgetCore.API;
  2. using UnityEngine;
  3. namespace AncientReassembler
  4. {
  5. public static class ItemUtil
  6. {
  7. public static TileInfo CreatePlacableItem(string tileImgPath, string itemImgPath, string name, GameObject tileObject)
  8. {
  9. Texture2D textureTile = GadgetCoreAPI.LoadTexture2D(tileImgPath);
  10. Texture2D textureItem = GadgetCoreAPI.LoadTexture2D(itemImgPath);
  11. GameObject gameObject = Object.Instantiate(tileObject);
  12. gameObject.name = name;
  13. ItemInfo itemInfo = new ItemInfo(ItemType.GENERIC, name, "", textureItem);
  14. itemInfo.Register(name);
  15. var tile = new TileInfo(TileType.INTERACTIVE, textureTile, gameObject, itemInfo);
  16. tile.Register(name);
  17. return tile;
  18. }
  19. }
  20. }