ItemUtil.cs 777 B

12345678910111213141516171819202122232425
  1. using GadgetCore.API;
  2. using UnityEngine;
  3. namespace StasisPod
  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. gameObject.AddComponent<StasisPodScript>();
  14. ItemInfo itemInfo = new ItemInfo(ItemType.GENERIC, name, "", textureItem);
  15. itemInfo.Register(name);
  16. var tile = new TileInfo(TileType.INTERACTIVE, textureTile, gameObject, itemInfo);
  17. tile.Register(name);
  18. return tile;
  19. }
  20. }
  21. }