Home > Mobile >  OnMouseOver with Collider 2D dont Worked in unity
OnMouseOver with Collider 2D dont Worked in unity

Time:04-17

I tried to use onm ouseOver to "select" a sprite that I would like to change the color by clicking, but I hover over the object that is inside a screen and nothing happens.

PixelManager Script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PixelManager : MonoBehaviour
{
    SpriteRenderer sRend;

    private void Start(){
        sRend = GetComponent<SpriteRenderer>();
    }

    private void onm ouseOver(){
        Debug.Log("Worked onm ouseOver");
        if(Input.GetMouseButton(0)){
            Debug.Log("Pressed left click.");
            sRend.color = transform.parent.GetComponent<GridManager>().GetCurrentColour();
            
        }
    }
}

sprite properties

CodePudding user response:

Capitalise the “O” in OnMouseOver().

  • Related