unity-types 6000.3.0 → 6000.3.2
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.
- package/OneJS.d.ts +981 -0
- package/README.md +97 -11
- package/Unity.InputSystem.d.ts +5361 -0
- package/UnityEngine.AudioModule.d.ts +791 -4
- package/UnityEngine.CoreModule.d.ts +16187 -4
- package/UnityEngine.InputLegacyModule.d.ts +199 -4
- package/UnityEngine.Physics2DModule.d.ts +3287 -0
- package/UnityEngine.PhysicsModule.d.ts +1251 -4
- package/UnityEngine.UIElementsModule.d.ts +6098 -4
- package/UnityEngine.UnityWebRequestModule.d.ts +214 -0
- package/_system.d.ts +578 -0
- package/index.d.ts +38 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,36 +6,122 @@ TypeScript definitions for Unity, designed for use with [OneJS](https://onejs.co
|
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
|
-
Install the version matching your Unity version:
|
|
10
|
-
|
|
11
9
|
```bash
|
|
12
|
-
npm install unity-types
|
|
10
|
+
npm install -D unity-types@~6000.3.0
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Setup
|
|
14
|
+
|
|
15
|
+
Add `unity-types` to your `tsconfig.json`:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"compilerOptions": {
|
|
20
|
+
"types": ["unity-types"],
|
|
21
|
+
"skipLibCheck": true
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
> **Note:** `skipLibCheck: true` is recommended. Some C# constructs (like compiler-generated fixed buffers) produce type names that aren't valid TypeScript identifiers.
|
|
27
|
+
|
|
28
|
+
Or add a triple-slash reference in a `global.d.ts` file:
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
/// <reference types="unity-types" />
|
|
13
32
|
```
|
|
14
33
|
|
|
15
34
|
## Usage
|
|
16
35
|
|
|
17
|
-
The
|
|
36
|
+
The `CS` namespace is globally available after setup:
|
|
18
37
|
|
|
19
38
|
```typescript
|
|
39
|
+
// Create a GameObject
|
|
20
40
|
const go = new CS.UnityEngine.GameObject("MyObject")
|
|
41
|
+
|
|
42
|
+
// Access transform
|
|
21
43
|
const pos: CS.UnityEngine.Vector3 = go.transform.position
|
|
44
|
+
pos.x = 10
|
|
45
|
+
|
|
46
|
+
// UI Elements
|
|
47
|
+
const button = new CS.UnityEngine.UIElements.Button()
|
|
48
|
+
button.text = "Click me"
|
|
49
|
+
|
|
50
|
+
// Physics
|
|
51
|
+
const rb: CS.UnityEngine.Rigidbody = go.AddComponent($typeof(CS.UnityEngine.Rigidbody))
|
|
52
|
+
rb.mass = 5
|
|
53
|
+
|
|
54
|
+
// Audio
|
|
55
|
+
const audio: CS.UnityEngine.AudioSource = go.GetComponent($typeof(CS.UnityEngine.AudioSource))
|
|
56
|
+
audio.Play()
|
|
57
|
+
|
|
58
|
+
// Web requests
|
|
59
|
+
const request = CS.UnityEngine.Networking.UnityWebRequest.Get("https://api.example.com")
|
|
22
60
|
```
|
|
23
61
|
|
|
24
62
|
## Included Assemblies
|
|
25
63
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
64
|
+
| Assembly | Size | Description |
|
|
65
|
+
|----------|------|-------------|
|
|
66
|
+
| `UnityEngine.CoreModule` | ~1 MB | GameObject, Transform, Vector3, Color, MonoBehaviour, etc. |
|
|
67
|
+
| `UnityEngine.UIElementsModule` | ~350 KB | VisualElement, Button, Label, TextField, etc. |
|
|
68
|
+
| `UnityEngine.PhysicsModule` | ~88 KB | Rigidbody, Collider, Physics, RaycastHit, etc. |
|
|
69
|
+
| `UnityEngine.Physics2DModule` | ~262 KB | Rigidbody2D, Collider2D, Physics2D, etc. |
|
|
70
|
+
| `UnityEngine.AudioModule` | ~41 KB | AudioSource, AudioClip, AudioListener, etc. |
|
|
71
|
+
| `UnityEngine.InputLegacyModule` | ~9 KB | Input, KeyCode, Touch, etc. |
|
|
72
|
+
| `UnityEngine.UnityWebRequestModule` | ~14 KB | UnityWebRequest, DownloadHandler, etc. |
|
|
73
|
+
| `Unity.InputSystem` | ~342 KB | InputAction, InputDevice, Keyboard, Mouse, etc. |
|
|
74
|
+
|
|
75
|
+
## Helper Types
|
|
76
|
+
|
|
77
|
+
The package includes helper types for C# interop:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
// Reference parameters (ref keyword in C#)
|
|
81
|
+
declare interface $Ref<T> { __doNotAccess: T }
|
|
82
|
+
|
|
83
|
+
// Output parameters (out keyword in C#)
|
|
84
|
+
declare interface $Out<T> { __doNotAccess: T }
|
|
85
|
+
|
|
86
|
+
// Task/async return types
|
|
87
|
+
declare interface $Task<T> { __doNotAccess: T }
|
|
88
|
+
```
|
|
31
89
|
|
|
32
90
|
## Versioning
|
|
33
91
|
|
|
34
|
-
Package versions match Unity versions
|
|
92
|
+
Package versions match Unity versions:
|
|
35
93
|
|
|
36
94
|
| Package Version | Unity Version |
|
|
37
95
|
|-----------------|---------------|
|
|
38
|
-
| `6000.3.
|
|
96
|
+
| `6000.3.x` | Unity 6000.3.x |
|
|
97
|
+
|
|
98
|
+
Use semver ranges to get compatible updates:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Exact version
|
|
102
|
+
npm install -D unity-types@6000.3.0
|
|
103
|
+
|
|
104
|
+
# Compatible updates within Unity 6000.3
|
|
105
|
+
npm install -D unity-types@~6000.3.0
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Generating Custom Types
|
|
109
|
+
|
|
110
|
+
If you need types for additional Unity assemblies or your own C# code, use the TypeGenerator in Unity:
|
|
111
|
+
|
|
112
|
+
```csharp
|
|
113
|
+
// Via menu: OneJS > Type Generator
|
|
114
|
+
|
|
115
|
+
// Or programmatically:
|
|
116
|
+
TypeGenerator.GenerateFromAssembly("output.d.ts", "MyGame.Core");
|
|
117
|
+
|
|
118
|
+
// Or use the fluent API:
|
|
119
|
+
TypeGenerator.Create()
|
|
120
|
+
.AddType<MyCustomClass>()
|
|
121
|
+
.AddNamespace("MyGame.Systems")
|
|
122
|
+
.Build()
|
|
123
|
+
.WriteTo("my-types.d.ts");
|
|
124
|
+
```
|
|
39
125
|
|
|
40
126
|
## License
|
|
41
127
|
|