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)Resources.Load("prop/" + 2401)); gameObject.GetComponentInChildren().color = color; Renderer renderer = gameObject.GetComponentInChildren(); renderer.material = new Material(Shader.Find("Transparent/Diffuse")) { mainTexture = textureTile }; ItemInfo itemInfo = new ItemInfo(ItemType.GENERIC, name, "", textureItem); int itemID = ItemRegistry.Singleton.Register(itemInfo, name); if (itemID == -1) throw new System.Exception("Could not register Item " + name); TileInfo tileInfo = new TileInfo(TileType.NONSOLID, textureTile, gameObject, itemInfo); int tileID = TileRegistry.Singleton.Register(tileInfo, name); if (tileID == -1) throw new System.Exception("Could not register Tile " + name); return itemID; } } }