有时候,可能会需要后台设置gameobject的锚点
UIPanel uipanel = this.gameObject.GetComponent<UIPanel>(); uipanel.SetAnchor(GameObject.Find("UI Root")); uipanel.leftAnchor.absolute = 0; uipanel.rightAnchor.absolute = 0; uipanel.topAnchor.absolute = 0; uipanel.bottomAnchor.absolute = 0;