简体   繁体   中英

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. I would like to find a way to differenciate between them, since they're both stored in public Image m_targetImage . I know their height/width. Is there any way to do something like 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?

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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM