mirror of
https://github.com/DerTyp7/industrialize-unity.git
synced 2025-10-30 12:57:11 +01:00
conveyorPO
This commit is contained in:
@@ -4,13 +4,22 @@ using UnityEngine;
|
||||
public class ItemSO : ScriptableObject
|
||||
{
|
||||
public string id;
|
||||
public string name;
|
||||
public string itemName;
|
||||
public GameObject prefab;
|
||||
public Sprite icon;
|
||||
|
||||
public void Spawn(Vector3 position)
|
||||
public GameObject Spawn(Vector3 position)
|
||||
{
|
||||
GameObject item = Instantiate(prefab, position, Quaternion.identity);
|
||||
// Snap to grid
|
||||
|
||||
GridBuildingSystem.instance.buildingGrid.GetXY(position, out int x, out int y);
|
||||
|
||||
position = GridBuildingSystem.instance.buildingGrid.GetWorldPosition(x, y);
|
||||
|
||||
GameObject item = Instantiate(prefab, new Vector3(position.x, position.y, 0), Quaternion.identity);
|
||||
item.name = name;
|
||||
item.GetComponent<ItemObject>().itemSO = this;
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user