コード例 #1
0
 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();
 }
コード例 #2
0
    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);
    }
コード例 #3
0
    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));
    }