void PlaceItemCheck() { if (Input.touchCount > 0) { Ray myRay = mycam.ScreenPointToRay(Input.GetTouch(0).position); RaycastHit hit = new RaycastHit(); if (Physics.Raycast(myRay, out hit)) { TileBaseScript tileS; try { tileS = hit.collider.gameObject.GetComponent <TileBaseScript> (); } catch { return; } itemScript.x = tileS.x; itemScript.y = tileS.y; curItem.transform.position = tileS.transform.position; } } else { isPlacingItem = false; if (curItem != null) { itemScript.PlaceSelf(); //Destroy (curItem.gameObject); curItem = null; itemScript = null; } } }
void InstantiateItems() { foreach (ItemData myItem in mySave.itemData) { if (myItem != null) { if (myItem.type != -1) { ItemBaseScript reelItem = ((GameObject)Instantiate(itemPrefabs[myItem.type], transform.position, transform.rotation)).GetComponent <ItemBaseScript>(); reelItem.PlaceSelf(myItem.x, myItem.y); reelItem.gameObject.name = reelItem.gameObject.name + " " + itemID; itemID++; } } } }