kingBook

导航

UGUI 判断元素进入舞台

void LateUpdate () {
        if(!_isLoaded){
            RectTransform rectt=this.GetComponent<RectTransform>();
            float w=rectt.rect.width*0.01f;
            float h=rectt.rect.height*0.01f;
            float lowerx=rectt.position.x+rectt.rect.x*0.01f;
            float lowery=rectt.position.y+rectt.rect.y*0.01f;
            float upperx=lowerx+w;
            float uppery=lowery+h;
            //Game.W=640,Game.H=960设计尺寸大小
            bool isIntoX=lowerx<(Game.W*0.5f*0.01f);
            bool isIntoY=uppery>(-Game.H*0.5f*0.01f);
            if(isIntoX&&isIntoY){
                loadIcon();
            }
        }
    }

 

posted on 2017-04-11 11:47  kingBook  阅读(165)  评论(0编辑  收藏  举报