You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unity Academy User Agreement, GUI (Button / Label) Functions and Bug Fixes (#203)
* Unity Academy User Agreement Update and Bug Fixes
* Fixed a bug
* Fixed a bug about checking User Agreement checkbox status
* Unity Academy GUI (Button & Label) functions
* Improved Unity Academy GUI functions
* Unity Academy - Finished GUI functions
* Update documentation
Copy file name to clipboardExpand all lines: src/bundles/unity_academy/UnityAcademy.tsx
+54-11Lines changed: 54 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -162,6 +162,8 @@ class UnityAcademyJsInteropContext {
162
162
privateunityInstanceState;// [set by interop]
163
163
privateguiData : any[];// [get / clear by interop]
164
164
publicdimensionMode;
165
+
privateisShowingUnityAcademy : boolean;// [get by interop]
166
+
privatelatestUserAgreementVersion : string;
165
167
166
168
constructor(){
167
169
this.unityInstance=null;
@@ -180,6 +182,8 @@ class UnityAcademyJsInteropContext {
180
182
};
181
183
this.targetFrameRate=30;
182
184
185
+
this.latestUserAgreementVersion='unknown';
186
+
this.getLatestUserAgreementVersion();
183
187
184
188
// [ Why I don't put this into my module's own context? ]
185
189
// Since Unity Academy application needs to access this from the WASM side, and the Unity Academy WASM side can not access the module context under the js-slang evaluation scope since Unity Academy app is running totally separated from js-slang in the WASM virtual machine.
@@ -191,6 +195,7 @@ class UnityAcademyJsInteropContext {
* By default the scale of a GameObject is (1, 1, 1). Changing the scale of a GameObject along one axis will lead to a stretch or squeeze of the GameObject along that axis.
317
324
*
318
325
* @param gameObjectIdentifier The identifier for the GameObject that you want to change scale for.
319
326
* @param x The x component for the scale.
@@ -879,42 +886,69 @@ export function on_collision_exit(gameObjectIdentifier : GameObjectIdentifier, e
879
886
880
887
881
888
/**
882
-
* Draw a text (string) on the screen with given screen position.<br>
883
-
* The origin of screen space is upper-left corner and the positive Y axis is downward.<br>
884
-
* You should put this under the `Update` function (or a function that is called by the `Update` function) to keep the text in every frame.
889
+
* Draw a text (string) on the screen with given <b>screen space position</b> in the current frame.<br>
890
+
* The origin of screen space is upper-left corner and the positive Y direction is downward.<br>
891
+
* The drawn text will only last for one frame. You should put this under the `Update` function (or a function that is called by the `Update` function) to keep the text stays in every frame.<br>
885
892
*
886
893
* @param content The string you want to display on screen.
887
894
* @param x The x coordinate of the text (in screen position).
888
895
* @param y The y coordinate of the text (in screen position).
* Make a button on the screen with given screen position. When user clicks the button, the `onClick` function will be called.<br>
902
-
* The origin of screen space is upper-left corner and the positive Y axis is downward.<br>
903
-
* You should put this under the `Update` function (or a function that is called by the `Update` function) to keep the button in every frame.
911
+
* Make a button on the screen with given <b>screen space position</b> in the current frame. When user clicks the button, the `onClick` function will be called.<br>
912
+
* The origin of screen space is upper-left corner and the positive Y direction is downward.<br>
913
+
* The drawn button will only last for one frame. You should put this under the `Update` function (or a function that is called by the `Update` function) to keep the button stays in every frame.
914
+
* <br>
915
+
* <br>
916
+
* If this function is called by a lifecycle event function, then the `onClick` function in the fourth parameter could also be considered as a lifecycle event function.<br>
917
+
* This means that you can use other functions from this module inside the `onClick` function, even though the functions are not under the `Outside Lifecycle` category.<br>
* <b><u>Note that you need to use this module with a 'Native' variant of Source language, otherwise you may get strange errors.</u></b>
10
+
* <b><u>Note that you need to use this module with a '<i>Native</i>' variant of Source language, otherwise you may get strange errors.</u></b>
10
11
* <br>
11
12
* <br>
12
13
* <b>Lifecycle Event Functions</b><br>
@@ -24,15 +25,19 @@
24
25
* ● ===>`Update` is called on every GameObject once in every frame after `Start` have been called. <br>
25
26
* ● For the three collision detaction lifecycle event functions, please refer to `on_collision_enter`, `on_collision_stay` and `on_collision_exit` functions under the `Physics - Collision` category.<br>
26
27
* ● You can not bind multiple lifecycle functions of the same type to the same GameObject. For example, you can't bind two `Update` functions to the same GameObject. In this case, previously binded `Update` functions will be overwritten by the latest binded `Update` function.<br><br>
27
-
* <u><b>[IMPORTANT]</b> All functions in this module that is NOT under the "<b>Outside Lifecycle</b>" or "Maths" category need to call by Unity Academy lifecycle event functions (Start or Update) to work correctly. Failure to follow this rule may lead to noneffective or incorrect behaviors of the functions and may crash the Unity Academy instance.</u><br>
28
+
* <u><b>[IMPORTANT]</b> All functions in this module that is NOT under the "<b>Outside Lifecycle</b>" or "Maths" category need to call by Unity Academy lifecycle event functions (directly or intermediately) to work correctly. Failure to follow this rule may lead to noneffective or incorrect behaviors of the functions and may crash the Unity Academy instance.</u><br>
28
29
* For example:
29
30
* ```
30
-
* import {init_unity_academy_3d, instantiate, set_start, set_update, set_position} from 'unity_academy';
31
+
* import {init_unity_academy_3d, instantiate, set_start, set_update, set_position, set_rotation_euler} from 'unity_academy';
31
32
* init_unity_academy_3d(); // Correct, since this function is under the "Outside Lifecycle" category and it can be called outside lifecycle event functions.
32
33
* const cube = instantiate("cube"); // Correct
33
34
* set_position(cube, 1, 2, 3); // WRONG, since set_position should ONLY be called inside a lifecycle event function
34
35
* function my_start(gameObject){ // A sample Start event function which will be binded to cube by my_start later.
35
36
* set_position(gameObject, 1, 2, 3); // Correct, since the call to set_position is inside a lifecycle event function
37
+
* something_else(gameObject);
38
+
* }
39
+
* function something_else(obj){
40
+
* set_rotation_euler(obj, 0, 45, 45); // Correct, since the function "set_rotation_euler" is intermediately called by the lifecycle event function "my_start" through "something_else"
36
41
* }
37
42
* set_start(cube, my_start); // Correct
38
43
* ```
@@ -44,16 +49,16 @@
44
49
* <br>
45
50
* <br>
46
51
* <b>Key differences between 2D and 3D mode</b><br>
47
-
* ● In 2D mode the main camera renders the scene in <b>orthographic</b> mode (Z position is used to determine sequence when sprites overlapping), whereas in 3D mode the camera renders the scene in <b>perspective</b> mode. Moreover, 3D mode and 2D mode have different kinds of default camera controller.<br>
48
-
* ● In 2D mode, due to the loss of one dimension, for some values and axis in 3D coordinate system, they sometimes behaves differently with 3D mode. For example, some coordinate values is ignored in 2D mode. Whereas in 3D mode you can use the fully-supported 3D coordinate system. (Actually, in general, Unity Academy just simply uses 3D space and an orthographic camera to simulate 2D space.)<br>
49
-
* ● In 2D mode you need to use <b>instantiate_sprite</b> to create new GameObjects, whereas in 3D mode you need to use <b>instantiate</b> to create new GameObjects.<br>
50
-
* ● In 2D mode Unity Academy will use Rigidbody2D and 2D colliders like BoxCollider2D for physics engine (certain values for 3D physics engine in 2D physics engine is ignored and will always be zero), whereas in 3D mode Unity Academy use regular 3D rigidbody and 3D colliders to simulate 3D physics.<br>
51
-
* ● In 2D mode playing frame animations for sprite GameObjects is currently unavailable, whereas in 3D mode you need to use <b>play_animator_state</b> to play 3D animations.<br>
52
+
* ● <u>In 2D mode</u> the main camera renders the scene in <b>orthographic</b> mode (Z position is used to determine sequence when sprites overlapping), whereas <u>in 3D mode</u> the camera renders the scene in <b>perspective</b> mode. Moreover, 3D mode and 2D mode have different kinds of default camera controller.<br>
53
+
* ● <u>In 2D mode</u>, due to the loss of one dimension, for some values and axis in 3D coordinate system, they sometimes behaves differently with 3D mode. For example, some coordinate values is ignored in 2D mode. Whereas <u>in 3D mode</u> you can use the fully-supported 3D coordinate system. (Actually, in general, Unity Academy just simply uses 3D space and an orthographic camera to simulate 2D space.)<br>
54
+
* ● <u>In 2D mode</u> you need to use <b>instantiate_sprite</b> to create new GameObjects, whereas <u>in 3D mode</u> you need to use <b>instantiate</b> to create new GameObjects.<br>
55
+
* ● <u>In 2D mode</u> Unity Academy will use Rigidbody2D and 2D colliders like BoxCollider2D for physics engine (certain values for 3D physics engine in 2D physics engine is ignored and will always be zero), whereas <u>in 3D mode</u> Unity Academy use regular 3D rigidbody and 3D colliders to simulate 3D physics.<br>
56
+
* ● <u>In 2D mode</u> playing frame animations for sprite GameObjects is currently unavailable, whereas <u>in 3D mode</u> you need to use <b>play_animator_state</b> to play 3D animations.<br>
* ● 2D: +X denotes rightward, +Y denotes upward, Z value actually still exists and usually used for determining sequence of overlapping 2D GameObjects like sprites.
* ● <u>2D:</u> +X denotes rightward, +Y denotes upward, Z value actually still exists and usually used for determining sequence of overlapping 2D GameObjects like sprites.
57
62
* <br>
58
63
* <br>
59
64
* <b>Unity Academy Camera Control (only available when the default camera controllers are being used)</b><br>
0 commit comments