void _ui() { // topImage float top_image_height = (float)(55.5 / 667.0) * Display.main.systemHeight; TopImage.rectTransform.sizeDelta = new Vector2(Display.main.systemWidth, top_image_height); // logoImage float logoImage_posx = (float)(24.5 / 375.0) * Display.main.systemWidth, logoImage_posy = -(float)(13 / 667.0) * Display.main.systemHeight, logo_width = (float)(22.5 / 375.0) * Display.main.systemWidth, logo_height = (float)(579 / 453.0) * logo_width; LogoImage.rectTransform.sizeDelta = new Vector2(logo_width, logo_height); LogoImage.rectTransform.anchoredPosition3D = new Vector3(logoImage_posx, logoImage_posy, 0); // 设置按钮 float set_button_posx = -(float)(25 / 375.0) * Display.main.systemWidth, set_button_width = (float)(20.5 / 375.0) * Display.main.systemWidth; SettingButton.GetComponent <RectTransform>().sizeDelta = new Vector2(set_button_width, set_button_width); SettingButton.GetComponent <RectTransform>().anchoredPosition3D = new Vector3(set_button_posx, 0, 0); // 应用文本 float app_posx = (float)(34 / 375.0) * Display.main.systemWidth, app_width = Display.main.systemWidth - app_posx - logoImage_posx + set_button_posx - set_button_width, app_height = (float)(14 / 667.0) * Display.main.systemHeight; AppNameText.rectTransform.sizeDelta = new Vector2(app_width, app_height); AppNameText.rectTransform.anchoredPosition3D = new Vector3(app_posx, 0, 0); // 搜索按钮、扫一扫按钮 float search_button_width = (float)(136 / 375.0) * Display.main.systemWidth, search_button_posy = -(float)(163 / 667.0) * Display.main.systemHeight, scan_button_posy = (float)(149.5 / 667.0) * Display.main.systemHeight; ArButton.GetComponent <RectTransform>().sizeDelta = new Vector2(search_button_width, search_button_width); ArButton.GetComponent <RectTransform>().anchoredPosition3D = new Vector3(0, scan_button_posy, 0); SearchButton.GetComponent <RectTransform>().sizeDelta = new Vector2(search_button_width, search_button_width); SearchButton.GetComponent <RectTransform>().anchoredPosition3D = new Vector3(0, search_button_posy, 0); // 公司文本 float com_text_posy = (float)(23 / 667.0) * Display.main.systemHeight, com_text_width = (float)(128 / 375.0) * Display.main.systemWidth, com_text_height = (float)(12.5 / 128.0) * com_text_width; ComNameText.rectTransform.sizeDelta = new Vector2(com_text_width, com_text_height); ComNameText.rectTransform.anchoredPosition3D = new Vector3(0, com_text_posy, 0); // 线 float line_posx = (float)(8.5 / 375.0) * Display.main.systemWidth, line_width = (float)(49 / 375.0) * Display.main.systemWidth, line_height = Display.main.systemHeight > 667.0 ? (float)(0.5 / 667.0) * Display.main.systemHeight : 0.5f; LeftLineImage.rectTransform.sizeDelta = new Vector2(line_width, line_height); LeftLineImage.rectTransform.anchoredPosition3D = new Vector3(-line_posx, 0, 0); RightLineImage.rectTransform.sizeDelta = new Vector2(line_width, line_height); RightLineImage.rectTransform.anchoredPosition3D = new Vector3(line_posx, 0, 0); // 隐藏界面 SettingCanvas.SetActive(false); SearchCanvas.SetActive(false); DrugInfoCanvas.SetActive(false); UpdateCanvas.SetActive(false); }
void _ui() { // 整个界面Panel float panel_posx = Display.main.systemWidth, panel_width = Display.main.systemWidth, panel_height = Display.main.systemHeight; Panel.GetComponent <RectTransform>().sizeDelta = new Vector2(panel_width, panel_height); Panel.GetComponent <RectTransform>().anchoredPosition3D = new Vector3(panel_posx, 0, 0); // backButton float back_button_posx = (float)(15 / 375.0) * Display.main.systemWidth, back_button_posy = -(float)(36.5 / 667.0) * Display.main.systemHeight, back_button_width = (float)(31.5 / 375.0) * Display.main.systemWidth; BackButton.GetComponent <RectTransform>().sizeDelta = new Vector2(back_button_width, back_button_width); BackButton.GetComponent <RectTransform>().anchoredPosition3D = new Vector3(back_button_posx, back_button_posy, 0); // helloText float hello_text_posy = -(float)(208.5 / 667.0) * Display.main.systemHeight, hello_text_width = (float)(97 / 375.0) * Display.main.systemWidth, hello_text_height = (float)(13 / 97.0) * hello_text_width; HelloText.rectTransform.sizeDelta = new Vector2(hello_text_width, hello_text_height); HelloText.rectTransform.anchoredPosition3D = new Vector3(0, hello_text_posy, 0); // 输入框 float input_field_posx = -(float)(24 / 375.0) * Display.main.systemWidth, input_field_posy = -(float)(37.5 / 667.0) * Display.main.systemHeight, input_filed_width = (float)(294 / 375.0) * Display.main.systemWidth, input_filed_height = (float)(30 / 667.0) * Display.main.systemHeight; InputField.GetComponent <RectTransform>().sizeDelta = new Vector2(input_filed_width, input_filed_height); InputField.GetComponent <RectTransform>().anchoredPosition3D = new Vector3(input_field_posx, input_field_posy, 0); // searchButton、image float search_button_width = (float)(36 / 375.0) * Display.main.systemWidth, search_button_height = (float)(34 / 36.0) * search_button_width, search_image_posx = -(float)(6 / 375.0) * Display.main.systemWidth, search_image_width = (float)(19.77 / 375.0) * Display.main.systemWidth, search_image_height = (float)(15.471 / 19.77) * search_image_width; SearchButton.GetComponent <RectTransform>().sizeDelta = new Vector2(search_button_width, search_button_height); SearchImage.rectTransform.anchoredPosition3D = new Vector3(search_image_posx, 0, 0); SearchImage.rectTransform.sizeDelta = new Vector2(search_image_width, search_image_height); // 输入框文本 float inputfiled_text_posx = (float)(20 / 375.0) * Display.main.systemWidth, inputfiled_text_height = (float)(16 / 667.0) * Display.main.systemHeight; InputFieldText.rectTransform.anchoredPosition3D = new Vector3(inputfiled_text_posx, 0, 0); InputFieldText.rectTransform.sizeDelta = new Vector2(InputField.GetComponent <RectTransform>().rect.width - inputfiled_text_posx - SearchButton.GetComponent <RectTransform>().rect.width, inputfiled_text_height); // scorllPanel float scorll_panel_posy = -(float)(80 / 667.0) * Display.main.systemHeight, scorll_panel_height = Display.main.systemHeight + scorll_panel_posy; ScorllPanel.GetComponent <RectTransform>().sizeDelta = new Vector2(Display.main.systemWidth, scorll_panel_height); ScorllPanel.GetComponent <RectTransform>().anchoredPosition3D = new Vector3(0, scorll_panel_posy, 0); // moreButton var more_button_height = (float)(44.5 / 667.0) * Display.main.systemHeight; var more_button_width = (float)((375.0 - 25.5 - 24.5) / 375.0) * Display.main.systemWidth; var more_button_text_height = (float)(12.5 / 667.0) * Display.main.systemHeight; MoreButton.GetComponent <RectTransform>().sizeDelta = new Vector2(more_button_width, more_button_height); MoreButton.transform.GetChild(0).GetComponent <Text>().rectTransform.sizeDelta = new Vector2(MoreButton.transform.GetChild(0).GetComponent <Text>().rectTransform.sizeDelta.x, more_button_text_height); // maskPanel var mask_panel_bottom = (float)(65.5 / 667.0) * Display.main.systemHeight; var mask_panel_height = (float)(Display.main.systemHeight - mask_panel_bottom - Mathf.Abs(ScorllPanel.GetComponent <RectTransform>().anchoredPosition3D.y)); MaskPanel.GetComponent <RectTransform>().sizeDelta = new Vector2(Display.main.systemWidth, mask_panel_height); // animation image var animation_image_posy = -(float)(Display.main.systemHeight / 4.0); if (animation_image_posy > InputField.GetComponent <RectTransform>().anchoredPosition3D.y - InputField.GetComponent <RectTransform>().rect.height) { animation_image_posy = InputField.GetComponent <RectTransform>().anchoredPosition3D.y - InputField.GetComponent <RectTransform>().rect.height; } //var animation_image_width = (float)(101 / 375.0) * Display.main.systemWidth; //var animation_image_height = (float)(107 / 101.0) * animation_image_width; //AnimationImage.rectTransform.sizeDelta = new Vector2(animation_image_width, animation_image_height); AnimationImage.rectTransform.anchoredPosition3D = new Vector3(0, animation_image_posy, 0); }