Have colision problems

Hi all .i need some support here.

I trying to create Xonix clone game in Unity but without Unity physics.So i need to wright colision script and create empty scene with 2 game objects (sprites) and give them textures. And get some problems with colision in my scene.

If i put exact coordinates _goodObjectPosition (1f, 2f)/_evilObjectPosition(1f, 2f) it works .But script didnt use my rectangles for colision check .Script doing only position check. How can i fix this?

using UnityEngine;
using System.Drawing;

public class Colision : MonoBehaviour
{
    //here  obj from scene
    public GameObject GoodObject;
    public GameObject EvilObject;

    //here  coords obj from scene
    private Vector2 _goodObjectPosition;
    private Vector2 _evilObjectPosition;

    //here  texture with heigth/width
    public RectTransform GoodObjectTexture;
    public RectTransform EvilObjectTexture;

    //here  sprites for marking collision
    private SpriteRenderer _spriteGoodTexture;
    private SpriteRenderer _spriteEvilTexture;

    //here rectangles for collision
    private Point _goodRectSize;
    private Point _evilRectSize;



    public void Start()
    {
        //add my sprites/textures option "Color change"
        _spriteGoodTexture = GoodObject.GetComponent<SpriteRenderer>();
        _spriteEvilTexture = EvilObject.GetComponent<SpriteRenderer>();

        //add start position and coords for Collision check
        _goodObjectPosition = new Vector2(1f, 2f);
       _evilObjectPosition = new Vector2(1f, 2f);

        //add 2 rectangles with height and width for Collision check
        _goodRectSize = new Point((int)GoodObjectTexture.rect.height, (int)GoodObjectTexture.rect.width);
       _evilRectSize = new Point((int)EvilObjectTexture.rect.height, (int)EvilObjectTexture.rect.width);
    }
    public bool Collide()

    {
        // here 2 rectangles get x,y positions and rectangles width,height for checking collision and return true or false

        Rectangle goodSpriteRect = new Rectangle((int)_goodObjectPosition.x,
            (int)_goodObjectPosition.y, _goodRectSize.X, _goodRectSize.Y);
        Rectangle evilSpriteRect = new Rectangle((int)_evilObjectPosition.x,
       (int)_evilObjectPosition.x, _evilRectSize.X, _evilRectSize.Y);

        return goodSpriteRect.IntersectsWith(evilSpriteRect);
    }
    public void Update()
        //here mark 2 sprites red if Coloide() set true and blue if false
    {
        if (Collide())
        {
            _spriteGoodTexture.color = UnityEngine.Color.red;
            _spriteEvilTexture.color = UnityEngine.Color.red;
        }
        else
        {
            _spriteEvilTexture.color = UnityEngine.Color.blue;
            _spriteGoodTexture.color = UnityEngine.Color.blue;
        }

    }
}

@ig866

Why are you creating a poll when you are just asking a question?

“And get some problems with colision in my scene.”

By this do you mean you are not using Physics for collision detection, and your rectangle overlap test is not working?

“.But script didnt use my rectangles for colision check .Script doing only position check. How can i fix this?”

I have no idea what you mean by this, but I would create another very simple tester script and see if you can get the overlap test working there. IMO easiest way to calculate rectangles for any sprite / gameobject is to use the Rect signature that takes transform position and size - this works fine if your pivot is centered in object.

It should work just fine, you probably have calculated something incorrectly (didn’t read your code properly).