private GameObject CreateGameObject(string _resourcePath, string _name, int _x, int _y, ref GameObject _level, bool _isTile, bool _isProp, bool _isDecal, bool _isBlank) { Level levelScript = _level.GetComponent <Level>(); GameObject go = Instantiate(Resources.Load(_resourcePath)) as GameObject; if (go == null) { Debug.LogError(_resourcePath); } go.name = "_" + _name + _y + ":" + _x; go.transform.parent = _level.transform; SpriteRenderer goSpriteRenderer = go.GetComponent <SpriteRenderer>(); go.transform.position = new Vector2(goSpriteRenderer.size.x * _x, goSpriteRenderer.size.y * _y); if (_isTile) { levelScript.tileLayer[_y, _x] = go; Tile tileScript = go.GetComponent <Tile>(); tileScript.SetXY(_x, _y); tileScript.SetStaringInfo(_x, _y); } else if (_isProp) { levelScript.propLayer[_y, _x] = go; Prop prop = go.GetComponent <Prop>(); prop.SetIsBlank(_isBlank); prop.SetXY(_x, _y); prop.SetStartingInfo(prop.transform.position, _x, _y); } else if (_isDecal) { levelScript.decalLayer[_y, _x] = go; Decal decal = go.GetComponent <Decal>(); decal.SetXY(_x, _y); } return(go); }