void Start() { origBlueprint = MaterialTexture.Copy(Resources.Load <Texture2D>("Blueprints/body_blueprint")); mask = MaterialShape.GenerateMask( Resources.Load <Texture2D>("Blueprints/body_blueprint_mask") ); wood = Resources.Load <Texture2D>("Materials/BaseTexture/wood"); nyan = Resources.Load <Texture2D>("Materials/BaseTexture/nyan"); UpdateSprite(); }
public void SetPart(PartType type, Texture2D blueprint, Texture2D blueprintMask) { this.type = type; this.texture = MaterialTexture.Copy(blueprint); this.blueprintMask = MaterialShape.GenerateMask(blueprintMask); GetComponent <Image>().sprite = Sprite.Create( texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f)); GetComponent <RectTransform>().sizeDelta = new Vector2(texture.width, texture.height); }
public void UpdateSprite() { bool[,] shapeMask = MaterialShape.PolygonFillMask(512, 256, MaterialShape.square, true); Texture2D shape = MaterialTexture.CreateTextureFromMask( shapeMask, nyan, new Vector2Int(x, y)); blueprint = MaterialTexture.Copy(origBlueprint); MaterialTexture.Paste(blueprint, mask, shape, Vector2Int.zero); GetComponent <Image>().sprite = Sprite.Create( blueprint, new Rect(0, 0, blueprint.width, blueprint.height), new Vector2(0.5f, 0.5f)); }