Ejemplo n.º 1
0
    void Start()
    {
        //reference to CreateLevelCollider script
        createCollider = GetComponent <CreateLevelCollider>();
        //reference to sprite renderer
        sr = GetComponent <SpriteRenderer>();
        //Create clone of the texture, so we won't alter(f**k up) the original
        Texture2D tex_clone = (Texture2D)Instantiate(tex);

        //Create a sprite from the cloned texture and set it as texture in the spriterenderer
        sr.sprite = Sprite.Create(tex_clone, new Rect(0f, 0f, tex.width, tex.height), new Vector2(0.5f, 0.5f));
        //make a transparant colour(Color.clear would also work, but now you kind of make it yourself)
        hole = new Color(0f, 0f, 0f, 0f);
        //Set the properties according to the sizes of the new sprite
        SetDimensions();
        //let the bullet know what the ground is
        HandleExplosion.groundController = this;
        // set collider on gameobject
        createCollider.SetCollider();
    }