Skip to content

Commit c951fc9

Browse files
author
Release Automat
committed
Release 11.0.2
1 parent 062674c commit c951fc9

File tree

8 files changed

+74
-20
lines changed

8 files changed

+74
-20
lines changed

Packages/tlp.udonutils/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ The used pattern MAJOR.MINOR.PATCH indicates:
3636

3737
All notable changes to this project will be documented in this file.
3838

39+
### [11.0.2] - 2024-12-19
40+
41+
#### 🐛 Bug Fixes
42+
43+
- *(Pool)* Fix exception when pool object has no UdonSharpBehaviour
44+
- *(Model)* NotifyIfDirty fails if Model not yet initialized
45+
- *(Task)* New tasks are in "Finished" state with result "Unknown"
46+
- *(StateMachine)* Fix null error on invalid state in AllStates
47+
- *(Model)* Ignore NotifyIfDirty errors if not dirty
48+
49+
#### 🚜 Refactor
50+
51+
- *(Task)* Magic strings to const variables
52+
3953
### [11.0.1] - 2024-12-13
4054

4155
#### 🐛 Bug Fixes

Packages/tlp.udonutils/Runtime/DesignPatterns/MVC/Model.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,18 @@ public bool NotifyIfDirty(int delayFrames = 0) {
128128
#endif
129129
#endregion
130130

131-
if (!HasStartedOk) {
131+
if (!Dirty) {
132+
return true;
133+
}
134+
135+
if (!IsReceivingStart && !HasStartedOk) {
132136
Error($"{nameof(NotifyIfDirty)}: Not initialized");
133137
return false;
134138
}
135139

136-
if (!Dirty) {
137-
return true;
140+
if (!IsModelInitialized) {
141+
Error($"{nameof(NotifyIfDirty)}: Model not initialized");
142+
return false;
138143
}
139144

140145
if (!Utilities.IsValid(ChangeEvent)) {

Packages/tlp.udonutils/Runtime/Experimental/Tasks/Task.cs

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
using System;
2-
using JetBrains.Annotations;
3-
using TLP.UdonUtils.Runtime.Common;
4-
using TLP.UdonUtils.Runtime.Player;
1+
using JetBrains.Annotations;
52
using UnityEngine;
63
using VRC.SDKBase;
74

85
namespace TLP.UdonUtils.Runtime.Experimental.Tasks
96
{
107
public enum TaskState
118
{
9+
Finished,
1210
Pending,
13-
Running,
14-
Finished
11+
Running
1512
}
1613

1714
public enum TaskResult
@@ -30,15 +27,16 @@ public abstract class Task : TlpBaseBehaviour
3027
public override int ExecutionOrderReadOnly => ExecutionOrder;
3128

3229
[PublicAPI]
33-
public new const int ExecutionOrder = TLP.UdonUtils.Runtime.Pool.Pool.ExecutionOrder + 50;
30+
public new const int ExecutionOrder = Runtime.Pool.Pool.ExecutionOrder + 50;
3431
#endregion
3532

36-
public TaskState State { get; private set; }
37-
public TaskResult Result { get; private set; }
33+
public TaskState State { get; private set; } = TaskState.Finished;
34+
public TaskResult Result { get; private set; } = TaskResult.Unknown;
3835

3936
internal TaskScheduler DefaultScheduler;
4037
internal TaskScheduler ActiveScheduler;
4138
internal TlpBaseBehaviour TaskInstigator;
39+
4240
/// <summary>
4341
/// In range 0 - 1 (inclusive)
4442
/// </summary>
@@ -61,7 +59,6 @@ internal bool PrepareForRun() {
6159
Result = TaskResult.Failed;
6260
State = TaskState.Finished;
6361
return false;
64-
6562
}
6663

6764
public bool Abort() {
@@ -83,6 +80,7 @@ public bool Abort() {
8380
ActiveScheduler.CancelTask(this);
8481
return true;
8582
}
83+
8684
Error($"{nameof(Abort)}: was not scheduled");
8785
return false;
8886
}
@@ -122,6 +120,13 @@ public TaskState Run() {
122120

123121
#region Internal
124122
protected void SetProgress(float progress) {
123+
#region TLP_DEBUG
124+
#if TLP_DEBUG
125+
DebugLog($"{nameof(SetProgress)}: {nameof(progress)}={progress}");
126+
#endif
127+
#endregion
128+
129+
125130
Progress = Mathf.Clamp01(progress);
126131
}
127132

Packages/tlp.udonutils/Runtime/Experimental/Tasks/TaskScheduler.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public class TaskScheduler : TlpSingleton
2222
public new const int ExecutionOrder = TlpExecutionOrder.RecordingEnd - 2;
2323
#endregion
2424

25+
public const string FinishedTaskVariableName = "FinishedTask";
26+
public const string FinishedTaskCallbackName = "OnTaskFinished";
2527
public const string GameObjectName = "TLP_TaskScheduler";
2628
internal readonly DataList PendingTasks = new DataList();
2729
internal readonly DataDictionary UniqueTasks = new DataDictionary();
@@ -194,8 +196,10 @@ private void RemoveTask(Task task, int index) {
194196
var instigator = (TlpBaseBehaviour)instigatorToken.Reference;
195197
if (Utilities.IsValid(instigator)) {
196198
instigator.EventInstigator = this;
197-
instigator.OnEvent("OnTaskFinished");
199+
instigator.SetProgramVariable(FinishedTaskVariableName, task);
200+
instigator.OnEvent(FinishedTaskCallbackName);
198201
instigator.EventInstigator = null;
202+
instigator.SetProgramVariable(FinishedTaskVariableName, null);
199203
} else {
200204
Error(
201205
$"{nameof(RemoveTask)}: {nameof(instigator)} invalid, {task.GetScriptPathInScene()} has no owner");

Packages/tlp.udonutils/Runtime/Pool/Pool.cs

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
using System;
2-
using JetBrains.Annotations;
1+
using JetBrains.Annotations;
2+
using TLP.UdonUtils.Runtime.Common;
33
using TLP.UdonUtils.Runtime.Events;
44
using TLP.UdonUtils.Runtime.Experimental.Tasks;
55
using UdonSharp;
66
using UnityEngine;
77
using UnityEngine.Serialization;
88
using VRC.SDKBase;
9+
10+
#if !COMPILER_UDONSHARP && UNITY_EDITOR
11+
#else
912
using VRC.Udon;
13+
#endif
1014

1115
namespace TLP.UdonUtils.Runtime.Pool
1216
{
@@ -159,7 +163,8 @@ public void Return(GameObject toReturn) {
159163
#endif
160164

161165
if (!Utilities.IsValid(instance)) {
162-
Warn($"{toReturn.name} has no UdonSharpBehaviour attached and will thus not be de-initialized");
166+
Warn(
167+
$"{toReturn.transform.GetPathInScene()} has no UdonSharpBehaviour attached and will thus not be de-initialized");
163168
} else {
164169
instance.SendCustomEvent(nameof(OnPrepareForReturnToPool));
165170
}
@@ -170,7 +175,9 @@ public void Return(GameObject toReturn) {
170175
toReturn.transform.parent = transform;
171176
}
172177

173-
instance.SetProgramVariable(nameof(PoolableInUse), false);
178+
if (Utilities.IsValid(instance)) {
179+
instance.SetProgramVariable(nameof(PoolableInUse), false);
180+
}
174181

175182
Pooled++;
176183
}

Packages/tlp.udonutils/Runtime/StateMachine/StateMachine.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,14 @@ public bool OwnerSetNewState(int newStateIndex) {
171171
StateMachineState.enabled = false;
172172
}
173173

174+
var newState = AllStates[newStateIndex];
175+
if (!Utilities.IsValid(newState)) {
176+
Error($"{nameof(OwnerSetNewState)}: {nameof(AllStates)} is null at index {newStateIndex}");
177+
return false;
178+
}
179+
174180
LocalStateIndex = newStateIndex;
175181
WorkingStateIndex = newStateIndex;
176-
var newState = AllStates[newStateIndex];
177182
StateMachineState = newState;
178183
newState.enabled = true;
179184
return true;

Packages/tlp.udonutils/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tlp.udonutils",
33
"displayName": "TLP UdonUtils",
4-
"version": "11.0.1",
4+
"version": "11.0.2",
55
"description": "Contains the base scripts/tools for TLP packages as well as prefabs and potentially helpful scripts for VRChat worlds.",
66
"gitDependencies": {},
77
"legacyFolders": {

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ The used pattern MAJOR.MINOR.PATCH indicates:
3636

3737
All notable changes to this project will be documented in this file.
3838

39+
### [11.0.2] - 2024-12-19
40+
41+
#### 🐛 Bug Fixes
42+
43+
- *(Pool)* Fix exception when pool object has no UdonSharpBehaviour
44+
- *(Model)* NotifyIfDirty fails if Model not yet initialized
45+
- *(Task)* New tasks are in "Finished" state with result "Unknown"
46+
- *(StateMachine)* Fix null error on invalid state in AllStates
47+
- *(Model)* Ignore NotifyIfDirty errors if not dirty
48+
49+
#### 🚜 Refactor
50+
51+
- *(Task)* Magic strings to const variables
52+
3953
### [11.0.1] - 2024-12-13
4054

4155
#### 🐛 Bug Fixes

0 commit comments

Comments
 (0)