/// <summary> /// ブロックを取得する /// </summary> /// <param name="attribute">ブロックの属性</param> /// <returns>ブロック</returns> public BlockBehaviour GetBlock(BlockAttribute attribute) { /// @todo プール化 var blockObject = GameObject.CreatePrimitive(PrimitiveType.Cube); var block = blockObject.AddComponent <BlockBehaviour>(); // 作り直す block.Renew(attribute); return(block); }
/// <summary> /// 作り直す /// </summary> /// <param name="attribute">属性</param> public void Renew(BlockAttribute attribute) { this.attribute = attribute; if (!BlockSingletonBehaviour.Exists()) { Debug.LogError("ブロック管理のインスタンスがありません"); return; } var renderer = this.GetOrAddComponent <Renderer>(); renderer.material = BlockSingletonBehaviour.Instance.GetBlockMaterial(this.attribute.type); }