| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using UnityEngine;
- using UnityEngine.UI;
- namespace DevilLink2.UI
- {
- // Fixed safe rectangles measured against UI11B artwork; owns no data, events or animation.
- public static class GameplayContentLayout
- {
- public static void Apply(GameHUD hud)
- {
- var panel=hud.transform.Find("HUDPanel");
- if(panel.Find("ContentRoot"))return;
- var content=UIBuilder.Rect("ContentRoot",panel,24,16,358,122);
- Place(hud.TimerLabel.transform,content,0,0,358,38);
- Place(hud.TimeFill.transform.parent,content,0,43,358,6);
- Place(hud.ScoreLabel.transform,content,0,59,178,26);
- Place(hud.ComboLabel.transform,content,194,59,164,26);
- Place(hud.PairsLabel.transform,content,0,91,178,22);
- Place(hud.ComboStateLabel.transform,content,194,87,164,18);
- Place(hud.ComboFill.transform.parent,content,194,114,164,4);
- // PNG682x658 inner rectangle approximately x90..592,y160..559.
- // Image is aspect preserved at 330/682 or 400/682, not the full panel rect.
- var pause=hud.Pause.transform.Find("Card");
- var title=pause.Find("Face/Heading");var note=pause.Find("Face/Note");
- var safe=UIBuilder.Rect("ContentRoot",pause,44,80,242,180);
- Place(title,safe,0,0,242,26);Place(note,safe,0,30,242,22);
- Button(hud.Pause.ResumeButton,safe,0,62,242,30);
- Button(hud.Pause.RestartButton,safe,0,102,242,30);
- Button(hud.Pause.LobbyButton,safe,0,142,242,30);
- var result=UIBuilder.Rect("ContentRoot",hud.Result.transform.Find("Card"),54,96,292,232);
- Place(hud.Result.Heading.transform,result,0,0,292,46);hud.Result.Heading.fontSize=19;
- Place(hud.Result.ScoreLabel.transform,result,0,48,292,46);hud.Result.ScoreLabel.fontSize=19;
- Place(hud.Result.RewardsLabel.transform,result,0,96,292,24);hud.Result.RewardsLabel.fontSize=12;
- Button(hud.Result.NextButton,result,0,128,292,28);
- Button(hud.Result.RetryButton,result,0,164,292,28);
- Button(hud.Result.LobbyButton,result,0,200,292,28);
- }
- private static void Place(Transform target,Transform parent,float x,float y,float w,float h)
- {target.SetParent(parent,false);UIBuilder.Place((RectTransform)target,x,y,w,h);}
- private static void Button(Button button,Transform parent,float x,float y,float w,float h)
- {
- Place(button.transform,parent,x,y,w,h);
- foreach(var image in button.GetComponentsInChildren<Image>(true))
- {
- if(image.transform==button.transform)continue;
- var r=image.rectTransform;r.anchorMin=Vector2.zero;r.anchorMax=Vector2.one;
- r.offsetMin=Vector2.one;r.offsetMax=-Vector2.one;
- }
- var text=button.GetComponentInChildren<Text>(true);UIBuilder.Place(text.rectTransform,4,0,w-8,h);
- }
- }
- }
|