| 123456789101112131415161718192021222324252627282930 |
- using GadgetCore.API;
- using UnityEngine;
- namespace MoreLights
- {
- public static class ItemUtil
- {
- public static int CreatePlacableLightItem(string tileImgPath, string itemImgPath, string name, Color color)
- {
- Texture2D textureTile = GadgetCoreAPI.LoadTexture2D(tileImgPath);
- Texture2D textureItem = GadgetCoreAPI.LoadTexture2D(itemImgPath);
- GameObject gameObject = Object.Instantiate<GameObject>((GameObject)Resources.Load("prop/" + 2401));
- gameObject.GetComponentInChildren<Light>().color = color;
- Renderer renderer = gameObject.GetComponentInChildren<Renderer>();
- renderer.material = new Material(Shader.Find("Transparent/Diffuse"))
- {
- mainTexture = textureTile
- };
- ItemInfo itemInfo = new ItemInfo(ItemType.GENERIC, name, "", textureItem);
- itemInfo.Register(name);
- new TileInfo(TileType.NONSOLID, textureTile, gameObject, itemInfo).Register(name);
- return itemInfo.GetID();
- }
- }
- }
|