SetMargin With RectTransform - Stretch
Nobody has claimed this yet.
- Dominant language
- Objective-C++
- Stars
- 2.7k
- Forks
- 734
- Avg merge
- 11h 39m
- Merged PRs (30d)
- 1
Description
Hello.
I have a problem with the size calculation of setMargin().
I looked for other issues that fit the size of the web view to RectTransform, but the difference is that I use Stretch (Ancher Preset).
Currently, I've succeeded in roughly sizing it, but I'm having trouble fitting it completely, and I don't know how to calculate the size.
I am attaching my code and a capture of the current situation. I'd appreciate your help.
int marginLeft = (int)_BG.offsetMin.x; // driven by RectTransform Property
int marginRight = Mathf.Abs((int)_BG.offsetMax.x);
int marginTop = Mathf.Abs((int)_BG.offsetMax.y);
int marginBottom = (int)_BG.offsetMin.y;
int screenWidth = Display.main.systemWidth;
int screenHeight = Display.main.systemHeight;
int left = marginLeft * screenWidth / 640; // 640, 1148 driven by Canvas Size
int top = marginTop * screenHeight / 1138;
int right = marginRight * screenWidth / 640;
int bottom = marginBottom * screenHeight / 1138;
Debug.Log($"{left} {top} {right} {bottom}");
_webview.SetMargins(left, top, right, bottom);
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file or test is named. Start by reviewing the attached Unity RectTransform Stretch setup and the margin calculation shown in the issue, then trace the _webview.SetMargins call; done means the web view fits the stretched RectTransform completely across the reported screen and canvas sizes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, unity
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100