Пример #1
0
    // Update is called once per frame
    void Update()
    {
        var v = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")).normalized;

        Debug.DrawLine(starBody.position, starBody.position + v, Color.red);
        starBody.velocity = v * speed;

        if (Input.GetKeyDown(KeyCode.M))
        {
            if (!sombrero)
            {
                sombrero = true;

                var top = Resources.Load <Texture2D>("sombrero");

                Texture2D combined = bottom.AlphaBlend(top);

                Sprite sprite = Sprite.Create(
                    combined,
                    new Rect(0, 0, combined.width, combined.height),
                    new Vector2(0.5f, 0.5f)
                    );



                gameObject.GetComponent <SpriteRenderer>().sprite = sprite;
            }
        }
    }