/// <summary> /// Loaded a Block from an BlockSave, but with a new Guid. Block can be loaded with an offset. Used for loading prefabs /// </summary> /// <param name="blockSave">The BlockSave to load</param> /// <param name="offset">Optional offset</param> /// <returns></returns> public GameObject LoadBlockWithNewGuid(BlockSave blockSave, Vector3 offset = new Vector3()) { GameObject restoredBlock = BlockGenerator.GenerateBlock(blockSave.GetBlockStructure()); restoredBlock.transform.position = blockSave.position + offset; restoredBlock.transform.rotation = blockSave.rotation; restoredBlock.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll; restoredBlock.GetComponentInChildren <TapHandler>().AcceptCollisionsAsConnected(true); restoredBlock.GetComponentInChildren <GrooveHandler>().AcceptCollisionsAsConnected(true); return(restoredBlock); }
/// <summary> /// Loads a Block from a BlockSave and freezes the Block, Block can be loaded with offset /// </summary> /// <param name="blockSave">The BlockSave to load</param> /// <param name="offset">Optionak offset</param> /// <returns></returns> public GameObject LoadBlock(BlockSave blockSave, Vector3 offset = new Vector3()) { GameObject restoredBlock = BlockGenerator.GenerateBlock(blockSave.GetBlockStructure()); restoredBlock.transform.position = blockSave.position + offset; restoredBlock.transform.rotation = blockSave.rotation; restoredBlock.GetComponent <BlockCommunication>().Guid = blockSave.guid; restoredBlock.GetComponent <BlockGeometryScript>().TopColliderContainer.layer = 8; restoredBlock.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll; restoredBlock.GetComponentInChildren <TapHandler>().AcceptCollisionsAsConnected(true); restoredBlock.GetComponentInChildren <GrooveHandler>().AcceptCollisionsAsConnected(true); return(restoredBlock); }