美文网首页
Unity 对象位置出错

Unity 对象位置出错

作者: Leo_909e | 来源:发表于2018-08-22 21:52 被阅读0次

如果挂了Layout组件的对象设置位置显示出错的情况,或者发现写的代码这一帧没有执行,或者考虑用协程延迟一帧来操作。

private void Co_DialogMoveType()

    {

        StartCoroutine (Delay_DialogMoveType());

    }

    IEnumerator Delay_DialogMoveType()

    {

        yield return 1;

        if (dialog != null) {

            ScrollRect sr = dialog.GetComponentInChildren ();

            if (sr != null) {

                sr.movementType = ScrollRect.MovementType.Elastic;

            }

        }

    }

相关文章

网友评论

      本文标题:Unity 对象位置出错

      本文链接:https://www.haomeiwen.com/subject/whrapftx.html