Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
Unity Webview
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FrameIT
Unity Webview
Compare revisions
312d50f9252f010879e67b3031fbd7a3f7be9fdb to db8544595c53245e2f77f6cb89a7829e1104b76e
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
FrameIT/unity-webview
Select target project
No results found
db8544595c53245e2f77f6cb89a7829e1104b76e
Select Git revision
Branches
main
1 result
Swap
Target
FrameIT/unity-webview
Select target project
FrameIT/unity-webview
1 result
312d50f9252f010879e67b3031fbd7a3f7be9fdb
Select Git revision
Branches
main
1 result
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source
3
Moved to use chrome-headless-shell.exe, as headless-old got deprecated
· a78b5dc3
baletiballo
authored
5 months ago
a78b5dc3
Automatically scale the browser tab to the size of the viewport
· 7aeeb0b0
baletiballo
authored
5 months ago
7aeeb0b0
hopefully avoid creating a tiny scrollbar
· db854459
baletiballo
authored
4 months ago
db854459
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Runtime/ChromeDevtools/Browser.cs
+1
-1
1 addition, 1 deletion
Runtime/ChromeDevtools/Browser.cs
Runtime/ChromeDevtools/BrowserTab.cs
+1
-7
1 addition, 7 deletions
Runtime/ChromeDevtools/BrowserTab.cs
Runtime/WebViewComponent.cs
+16
-10
16 additions, 10 deletions
Runtime/WebViewComponent.cs
with
18 additions
and
18 deletions
Runtime/ChromeDevtools/Browser.cs
View file @
db854459
...
...
@@ -17,7 +17,7 @@ namespace bessw.Unity.WebView.ChromeDevTools
private
Process
browserProcess
;
/* browser settings */
public
static
string
browserExecutablePath
=
"chrom
e"
;
public
static
string
browserExecutablePath
=
Application
.
streamingAssetsPath
+
"/chrome-headless-shell-win64/chrome-headless-shell.ex
e"
;
public
static
bool
headless
=
true
;
private
const
int
debugPort
=
9222
;
...
...
This diff is collapsed.
Click to expand it.
Runtime/ChromeDevtools/BrowserTab.cs
View file @
db854459
...
...
@@ -25,11 +25,6 @@ namespace bessw.Unity.WebView.ChromeDevTools
/// </summary>
public
Vector2Int
Size
{
get
;
private
set
;
}
/// <summary>
/// Scales the page in the browser tab
/// </summary>
public
int
PageScaleFactor
{
get
;
private
set
;
}
/// <summary>
/// width and height of the stream from the browser
/// </summary>
...
...
@@ -87,7 +82,7 @@ namespace bessw.Unity.WebView.ChromeDevTools
yield
return
devtools
.
readLoop
();
}
public
async
Task
SetSize
AndScale
(
Vector2Int
size
,
int
pageScaleFactor
)
public
async
Task
SetSize
(
Vector2Int
size
)
{
await
devtools
.
SendCommandAsync
(
new
setDeviceMetricsOverride
{
...
...
@@ -97,7 +92,6 @@ namespace bessw.Unity.WebView.ChromeDevTools
screenHeight
=
size
.
y
,
});
Size
=
size
;
PageScaleFactor
=
pageScaleFactor
;
}
/// <summary>
...
...
This diff is collapsed.
Click to expand it.
Runtime/WebViewComponent.cs
View file @
db854459
...
...
@@ -57,19 +57,22 @@ namespace bessw.Unity.WebView
public
event
Action
OnWebViewComponentReady
;
private
RawImage
rawImage
;
private
RectTransform
rectTransform
;
private
RectTransform
viewPort
;
private
Canvas
scaler
;
public
bool
headlessBrowser
=
true
;
//TODO: handle changed targetUrl
public
string
targetUrl
=
"https://google.de"
;
public
in
t
PageScaleFactor
=
3
;
//
public
floa
t PageScaleFactor =
2.0f; // We can just grab the factor of the canvas, no need for a manual number
// Start is called before the first frame update
private
void
Start
()
{
rawImage
=
this
.
gameObject
.
GetComponent
<
RawImage
>();
rectTransform
=
this
.
gameObject
.
GetComponent
<
RectTransform
>();
viewPort
=
this
.
gameObject
.
GetComponent
<
RectTransform
>();
scaler
=
this
.
gameObject
.
GetComponentInParent
<
Canvas
>();
Browser
.
headless
=
headlessBrowser
;
browser
=
Browser
.
getInstance
();
...
...
@@ -78,7 +81,9 @@ namespace bessw.Unity.WebView
var
c
=
StartCoroutine
(
browser
.
OpenNewTab
(
targetUrl
,
(
BrowserTab
bt
)
=>
{
tab
=
bt
;
_
=
tab
.
SetSizeAndScale
(
new
Vector2Int
((
int
)
rectTransform
.
rect
.
width
,
(
int
)
rectTransform
.
rect
.
height
)
/
PageScaleFactor
,
PageScaleFactor
);
// Set the size of the Tab to the size of the viewport
//_ = tab.SetSize(Vector2Int.RoundToInt(this.gameObject.GetComponentInParent<Canvas>().renderingDisplaySize));
OnRectTransformDimensionsChange
();
StartCoroutine
(
tab
.
Update
());
//StartCoroutine(createScreenshots());
...
...
@@ -95,10 +100,11 @@ namespace bessw.Unity.WebView
{
if
(
tab
is
not
null
)
{
var
size
=
new
Vector2Int
((
int
)
rectTransform
.
rect
.
width
,
(
int
)
rectTransform
.
rect
.
height
)
/
PageScaleFactor
;
if
(
tab
.
Size
!=
size
)
var
size
=
new
Vector2
(
viewPort
.
rect
.
width
,
viewPort
.
rect
.
height
)
*
scaler
.
scaleFactor
;
Vector2Int
sizeInt
=
Vector2Int
.
FloorToInt
(
size
);
if
(
tab
.
Size
!=
sizeInt
)
{
_
=
tab
.
SetSize
AndScale
(
size
,
PageScaleFactor
);
_
=
tab
.
SetSize
(
sizeInt
);
}
}
}
...
...
@@ -211,11 +217,11 @@ namespace bessw.Unity.WebView
private
Vector2Int
toBrowserCoordinates
(
Vector2
eventPos
)
{
RectTransformUtility
.
ScreenPointToLocalPointInRectangle
(
rectTransf
or
m
,
eventPos
,
null
,
out
Vector2
localPoint
);
RectTransformUtility
.
ScreenPointToLocalPointInRectangle
(
viewP
or
t
,
eventPos
,
null
,
out
Vector2
localPoint
);
// invert y because the browser has y=0 on the top
Vector2
invertedLocalPos
=
new
Vector2
(
localPoint
.
x
,
rectTransf
or
m
.
rect
.
size
.
y
-
localPoint
.
y
);
Vector2
textureScale
=
tab
.
StreamSize
/
rectTransf
or
m
.
rect
.
size
;
Vector2
invertedLocalPos
=
new
Vector2
(
localPoint
.
x
,
viewP
or
t
.
rect
.
size
.
y
-
localPoint
.
y
);
Vector2
textureScale
=
tab
.
StreamSize
/
viewP
or
t
.
rect
.
size
;
Vector2
browserCoordinate
=
invertedLocalPos
*
textureScale
;
// / tab.ViewportScaleFactor;
//Debug.Log($"eventPos: {eventPos}, invertedLocalPos: {invertedLocalPos}, browserCoordinate: {browserCoordinate}");
return
new
Vector2Int
((
int
)
browserCoordinate
.
x
,
(
int
)
browserCoordinate
.
y
);
...
...
This diff is collapsed.
Click to expand it.