onejs-core 2.0.18 → 2.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -395,6 +395,7 @@ declare namespace CS {
|
|
|
395
395
|
public SetTransitionProperty ($value: System.Collections.Generic.List$1<UnityEngine.UIElements.StylePropertyName>) : void
|
|
396
396
|
public SetTransitionTimingFunction ($value: System.Collections.Generic.List$1<UnityEngine.UIElements.EasingFunction>) : void
|
|
397
397
|
public SetTranslate ($value: UnityEngine.UIElements.Translate) : void
|
|
398
|
+
public SetTranslate (a: number, b: number) : void
|
|
398
399
|
public SetUnityBackgroundImageTintColor ($value: UnityEngine.Color) : void
|
|
399
400
|
public SetUnityBackgroundScaleMode ($value: UnityEngine.ScaleMode) : void
|
|
400
401
|
public SetUnityFont ($value: UnityEngine.Font) : void
|
package/dist/dom/document.d.ts
CHANGED
|
@@ -17,5 +17,7 @@ export declare class DocumentWrapper {
|
|
|
17
17
|
createTextNode(text: string): DomWrapper;
|
|
18
18
|
getElementById(id: string): DomWrapper;
|
|
19
19
|
querySelectorAll(selector: string): DomWrapper[];
|
|
20
|
+
elementFromPoint(x: number, y: number): DomWrapper | null;
|
|
21
|
+
elementsFromPoint(x: number, y: number): DomWrapper[];
|
|
20
22
|
}
|
|
21
23
|
export {};
|
package/dist/dom/document.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Vector2 } from "UnityEngine";
|
|
1
2
|
import { DomWrapper } from "./dom";
|
|
2
3
|
export class DocumentWrapper {
|
|
3
4
|
get _doc() { return this.#doc; }
|
|
@@ -38,4 +39,39 @@ export class DocumentWrapper {
|
|
|
38
39
|
}
|
|
39
40
|
return res;
|
|
40
41
|
}
|
|
42
|
+
elementFromPoint(x, y) {
|
|
43
|
+
const root = this.body;
|
|
44
|
+
if (!root)
|
|
45
|
+
return null;
|
|
46
|
+
const hitTest = (node) => {
|
|
47
|
+
if (!node.ve.worldBound.Contains(new Vector2(x, y)))
|
|
48
|
+
return null;
|
|
49
|
+
// later siblings are painted on top → scan from back to front
|
|
50
|
+
for (let i = node.childNodes.length - 1; i >= 0; i--) {
|
|
51
|
+
const hit = hitTest(node.childNodes[i]);
|
|
52
|
+
if (hit)
|
|
53
|
+
return hit;
|
|
54
|
+
}
|
|
55
|
+
return node;
|
|
56
|
+
};
|
|
57
|
+
return hitTest(root);
|
|
58
|
+
}
|
|
59
|
+
elementsFromPoint(x, y) {
|
|
60
|
+
const root = this.body;
|
|
61
|
+
if (!root)
|
|
62
|
+
return [];
|
|
63
|
+
const hits = [];
|
|
64
|
+
const collect = (node) => {
|
|
65
|
+
if (!node.ve.worldBound.Contains(new Vector2(x, y)))
|
|
66
|
+
return;
|
|
67
|
+
// visit children first, from front to back (last child is top‑most)
|
|
68
|
+
for (let i = node.childNodes.length - 1; i >= 0; i--) {
|
|
69
|
+
collect(node.childNodes[i]);
|
|
70
|
+
}
|
|
71
|
+
// add the current node itself
|
|
72
|
+
hits.push(node);
|
|
73
|
+
};
|
|
74
|
+
collect(root);
|
|
75
|
+
return hits; // ordered front‑to‑back (top‑most first)
|
|
76
|
+
}
|
|
41
77
|
}
|
package/dom/document.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Vector2 } from "UnityEngine"
|
|
1
2
|
import { DomWrapper } from "./dom"
|
|
2
3
|
|
|
3
4
|
interface ElementCreationOptions {
|
|
@@ -7,8 +8,8 @@ interface ElementCreationOptions {
|
|
|
7
8
|
export class DocumentWrapper {
|
|
8
9
|
public get _doc(): CS.OneJS.Dom.Document { return this.#doc }
|
|
9
10
|
|
|
10
|
-
#doc: CS.OneJS.Dom.Document
|
|
11
|
-
#body: DomWrapper | null
|
|
11
|
+
#doc: CS.OneJS.Dom.Document
|
|
12
|
+
#body: DomWrapper | null
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* The body/root element of the document. Will be null for Editor documents.
|
|
@@ -51,6 +52,46 @@ export class DocumentWrapper {
|
|
|
51
52
|
for (let i = 0; i < doms.Length; i++) {
|
|
52
53
|
res.push(new DomWrapper(doms.get_Item(i)))
|
|
53
54
|
}
|
|
54
|
-
return res
|
|
55
|
+
return res
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
elementFromPoint(x: number, y: number): DomWrapper | null {
|
|
59
|
+
const root = this.body
|
|
60
|
+
if (!root) return null
|
|
61
|
+
|
|
62
|
+
const hitTest = (node: DomWrapper): DomWrapper | null => {
|
|
63
|
+
if (!node.ve.worldBound.Contains(new Vector2(x, y))) return null
|
|
64
|
+
|
|
65
|
+
// later siblings are painted on top → scan from back to front
|
|
66
|
+
for (let i = node.childNodes.length - 1; i >= 0; i--) {
|
|
67
|
+
const hit = hitTest(node.childNodes[i])
|
|
68
|
+
if (hit) return hit
|
|
69
|
+
}
|
|
70
|
+
return node
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return hitTest(root)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
elementsFromPoint(x: number, y: number): DomWrapper[] {
|
|
77
|
+
const root = this.body
|
|
78
|
+
if (!root) return []
|
|
79
|
+
|
|
80
|
+
const hits: DomWrapper[] = []
|
|
81
|
+
|
|
82
|
+
const collect = (node: DomWrapper): void => {
|
|
83
|
+
if (!node.ve.worldBound.Contains(new Vector2(x, y))) return
|
|
84
|
+
|
|
85
|
+
// visit children first, from front to back (last child is top‑most)
|
|
86
|
+
for (let i = node.childNodes.length - 1; i >= 0; i--) {
|
|
87
|
+
collect(node.childNodes[i])
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// add the current node itself
|
|
91
|
+
hits.push(node)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
collect(root)
|
|
95
|
+
return hits // ordered front‑to‑back (top‑most first)
|
|
55
96
|
}
|
|
56
97
|
}
|
package/package.json
CHANGED