Unity C# 脚本:鼠标悬停放大组件大小
public bool isMouseOver = false; \nprivate Vector3 initialScale; \nprivate float scaleFactor = 1.1f; // 缩放因子 \n\n// Start is called before the first frame update \nvoid Start() \n{ \n\tinitialScale = transform.localScale; \n} \n\nvoid OnMouseEnter() \n{ \n\tisMouseOver = true; \n\ttransform.localScale = initialScale * scaleFactor; // 放大组件大小 \n} \n\nvoid OnMouseExit() \n{ \n\tisMouseOver = false; \n\ttransform.localScale = initialScale; // 恢复初始大小 \n}
原文地址: https://www.cveoy.top/t/topic/p3n0 著作权归作者所有。请勿转载和采集!