[英]Unity & C# How to check image's height/witdth or name?
public class FadeIn : MonoBehaviour
{
public Image m_targetImage;
if(m_targetImage.height = 360)
{
yield return new WaitForSeconds( m_stayDuration );
}
So there's more code in this script but its not really relevant to my question.所以这个脚本中有更多代码,但它与我的问题并不真正相关。 I'm using unity, and in there , I got this script attached to 2 images.
我正在使用 unity,在那里,我将此脚本附加到 2 个图像。 I would like to find a way to differenciate between them, since they're both stored in
public Image m_targetImage
.我想找到一种方法来区分它们,因为它们都存储在
public Image m_targetImage
。 I know their height/width.我知道它们的高度/宽度。 Is there any way to do something like
if(m_targetImage.height = x) then
?有没有办法做类似
if(m_targetImage.height = x) then
事情? I seem to find no answer to this.我似乎找不到答案。
If needed, here is the whole code : C# How to differenciate between Images in the same script?如果需要,这里是整个代码: C# 如何区分同一脚本中的图像?
If I am understanding you correctly, you are wondering if there is a way to check the width or height of an Image, which there is:如果我理解正确,您想知道是否有一种方法可以检查图像的宽度或高度,其中有:
if(m_targetImage.sprite.rect.height = x)
{
//code
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.