Estoy usando DOTween para que cuando pase el mouse sobre el botón, se resalte al agrandarse ligeramente y se interponga para que se vea suave. Sin embargo, tengo dos secuencias de comandos separadas adjuntas para cada botón que hacen exactamente lo mismo, pero cuando paso el mouse sobre uno de los botones, el otro botón también se agranda. Intenté usar los botones debajo del mismo lienzo que no funcionó. Entonces intenté usar dos lienzos para botones separados y sigue siendo el mismo problema. Se ve así: https://vimeo.com/user105553995/review/517200220/41fbe8d619
Mi código está en diferentes secuencias de comandos para cada botón, pero es exactamente el mismo:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using DG.Tweening; public class OtherButton : MonoBehaviour { // Start is called before the first frame update private Vector3 defaultScale; // Start is called before the first frame update void Start() { defaultScale = this.transform.localScale; } // Update is called once per frame void Update() { WhilePointerHover(); } private void WhilePointerHover() { if (EventSystem.current.IsPointerOverGameObject()) { Vector3 enlarge = defaultScale*1.2f; this.transform.DOScale(enlarge, 0.05f); Debug.Log(this.gameObject.name); } else this.transform.localScale = defaultScale; } }¡Cualquier ayuda es apreciada!
El código verifica si está sobre algún objeto de la interfaz de usuario, por lo que cualquier secuencia de comandos reaccionará.
Debe usar https://docs.unity3d.com/2019.1/Documentation/ScriptReference/UI.Selectable.OnPointerEnter.html
Y
https://docs.unity3d.com/2019.1/Documentation/ScriptReference/UI.Selectable.OnPointerExit.html
Por lo tanto, solo reaccionará al objeto al que está unido. Tenga en cuenta que el componente Imagen o Botón debe estar en el mismo objeto.