gree / gree/unity-webview

SetMargin With RectTransform - Stretch

Open
#858 1 comment 0 reactions 0 assignees View on GitHub

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);

Capture
Capture3
Capture2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.