Skip to content

Commit 19e6201

Browse files
authored
Merge pull request #2 from IvanMurzak/update/general-improvements
2 parents df9205b + 143a216 commit 19e6201

13 files changed

+219
-164
lines changed

Unity-Package/Assets/root/Editor/Scripts/Data.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/*
2+
┌─────────────────────────────────────────────────────────────────────────────┐
3+
│ Author: Ivan Murzak (https://github.com/IvanMurzak) │
4+
│ Repository: GitHub (https://github.com/IvanMurzak/Unity-AI-ParticleSystem) │
5+
│ Copyright (c) 2025 Ivan Murzak │
6+
│ Licensed under the MIT License. │
7+
│ See the LICENSE file in the project root for more information. │
8+
└─────────────────────────────────────────────────────────────────────────────┘
9+
*/
10+
11+
#nullable enable
12+
using System.ComponentModel;
13+
using com.IvanMurzak.ReflectorNet.Model;
14+
using com.IvanMurzak.Unity.MCP.Runtime.Data;
15+
16+
namespace com.IvanMurzak.Unity.MCP.ParticleSystem.Editor
17+
{
18+
/// <summary>
19+
/// Response model for Get ParticleSystem tool.
20+
/// </summary>
21+
[Description("Response containing ParticleSystem data with requested modules.")]
22+
public class GetParticleSystemResponse
23+
{
24+
[Description("Reference to the GameObject containing the ParticleSystem component.")]
25+
public GameObjectRef? gameObjectRef;
26+
27+
[Description("Reference to the ParticleSystem component.")]
28+
public ComponentRef? componentRef;
29+
30+
[Description("Index of the ParticleSystem component in the GameObject's component list.")]
31+
public int componentIndex = -1;
32+
33+
[Description("Whether the ParticleSystem is currently playing.")]
34+
public bool isPlaying;
35+
36+
[Description("Whether the ParticleSystem is currently paused.")]
37+
public bool isPaused;
38+
39+
[Description("Whether the ParticleSystem is currently emitting.")]
40+
public bool isEmitting;
41+
42+
[Description("Whether the ParticleSystem is currently stopped.")]
43+
public bool isStopped;
44+
45+
[Description("Current particle count.")]
46+
public int particleCount;
47+
48+
[Description("Current simulation time.")]
49+
public float time;
50+
51+
[Description("Main module data.")]
52+
public SerializedMember? main;
53+
54+
[Description("Emission module data.")]
55+
public SerializedMember? emission;
56+
57+
[Description("Shape module data.")]
58+
public SerializedMember? shape;
59+
60+
[Description("Velocity over Lifetime module data.")]
61+
public SerializedMember? velocityOverLifetime;
62+
63+
[Description("Limit Velocity over Lifetime module data.")]
64+
public SerializedMember? limitVelocityOverLifetime;
65+
66+
[Description("Inherit Velocity module data.")]
67+
public SerializedMember? inheritVelocity;
68+
69+
[Description("Lifetime by Emitter Speed module data.")]
70+
public SerializedMember? lifetimeByEmitterSpeed;
71+
72+
[Description("Force over Lifetime module data.")]
73+
public SerializedMember? forceOverLifetime;
74+
75+
[Description("Color over Lifetime module data.")]
76+
public SerializedMember? colorOverLifetime;
77+
78+
[Description("Color by Speed module data.")]
79+
public SerializedMember? colorBySpeed;
80+
81+
[Description("Size over Lifetime module data.")]
82+
public SerializedMember? sizeOverLifetime;
83+
84+
[Description("Size by Speed module data.")]
85+
public SerializedMember? sizeBySpeed;
86+
87+
[Description("Rotation over Lifetime module data.")]
88+
public SerializedMember? rotationOverLifetime;
89+
90+
[Description("Rotation by Speed module data.")]
91+
public SerializedMember? rotationBySpeed;
92+
93+
[Description("External Forces module data.")]
94+
public SerializedMember? externalForces;
95+
96+
[Description("Noise module data.")]
97+
public SerializedMember? noise;
98+
99+
[Description("Collision module data.")]
100+
public SerializedMember? collision;
101+
102+
[Description("Trigger module data.")]
103+
public SerializedMember? trigger;
104+
105+
[Description("Sub Emitters module data.")]
106+
public SerializedMember? subEmitters;
107+
108+
[Description("Texture Sheet Animation module data.")]
109+
public SerializedMember? textureSheetAnimation;
110+
111+
[Description("Lights module data.")]
112+
public SerializedMember? lights;
113+
114+
[Description("Trails module data.")]
115+
public SerializedMember? trails;
116+
117+
[Description("Custom Data module data.")]
118+
public SerializedMember? customData;
119+
120+
[Description("Renderer module data.")]
121+
public SerializedMember? renderer;
122+
}
123+
}

Unity-Package/Assets/root/Editor/Scripts/Data/GetParticleSystemResponse.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
┌─────────────────────────────────────────────────────────────────────────────┐
3+
│ Author: Ivan Murzak (https://github.com/IvanMurzak) │
4+
│ Repository: GitHub (https://github.com/IvanMurzak/Unity-AI-ParticleSystem) │
5+
│ Copyright (c) 2025 Ivan Murzak │
6+
│ Licensed under the MIT License. │
7+
│ See the LICENSE file in the project root for more information. │
8+
└─────────────────────────────────────────────────────────────────────────────┘
9+
*/
10+
11+
#nullable enable
12+
using System.ComponentModel;
13+
using com.IvanMurzak.Unity.MCP.Runtime.Data;
14+
15+
namespace com.IvanMurzak.Unity.MCP.ParticleSystem.Editor
16+
{
17+
/// <summary>
18+
/// Response model for Modify ParticleSystem tool.
19+
/// </summary>
20+
[Description("Response containing the result of modifying a ParticleSystem.")]
21+
public class ModifyParticleSystemResponse
22+
{
23+
[Description("Whether the modification was successful.")]
24+
public bool success;
25+
26+
[Description("Reference to the GameObject containing the ParticleSystem component.")]
27+
public GameObjectRef? gameObjectRef;
28+
29+
[Description("Reference to the modified ParticleSystem component.")]
30+
public ComponentRef? componentRef;
31+
32+
[Description("Index of the ParticleSystem component in the GameObject's component list.")]
33+
public int componentIndex = -1;
34+
35+
[Description("Log of modifications made and any warnings/errors encountered.")]
36+
public string[]? logs;
37+
}
38+
}

Unity-Package/Assets/root/Editor/Scripts/Data/ModifyParticleSystemResponse.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Unity-Package/Assets/root/Editor/Scripts/Tools/ParticleSystemData.cs renamed to Unity-Package/Assets/root/Editor/Scripts/Data/ParticleSystemData.cs

Lines changed: 1 addition & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
using com.IvanMurzak.ReflectorNet.Model;
1414
using com.IvanMurzak.Unity.MCP.Runtime.Data;
1515

16-
namespace com.IvanMurzak.Unity.MCP.ParticleSystem.Editor.API
16+
namespace com.IvanMurzak.Unity.MCP.ParticleSystem.Editor
1717
{
1818
/// <summary>
1919
/// Data model for ParticleSystem component containing serialized data for all modules.
@@ -104,132 +104,4 @@ public class ParticleSystemData
104104
[Description("Renderer module data: renderMode, sortMode, lengthScale, velocityScale, cameraVelocityScale, normalDirection, sortingFudge, minParticleSize, maxParticleSize, alignment, flip, allowRoll, pivot, maskInteraction, material, trailMaterial, shadowCastingMode, receiveShadows, shadowBias, motionVectorGenerationMode, sortingLayerID, sortingLayerName, sortingOrder, lightProbeUsage, reflectionProbeUsage, probeAnchor.")]
105105
public SerializedMember? renderer;
106106
}
107-
108-
/// <summary>
109-
/// Response model for Get ParticleSystem tool.
110-
/// </summary>
111-
[Description("Response containing ParticleSystem data with requested modules.")]
112-
public class GetParticleSystemResponse
113-
{
114-
[Description("Reference to the GameObject containing the ParticleSystem component.")]
115-
public GameObjectRef? gameObjectRef;
116-
117-
[Description("Reference to the ParticleSystem component.")]
118-
public ComponentRef? componentRef;
119-
120-
[Description("Index of the ParticleSystem component in the GameObject's component list.")]
121-
public int componentIndex = -1;
122-
123-
[Description("Whether the ParticleSystem is currently playing.")]
124-
public bool isPlaying;
125-
126-
[Description("Whether the ParticleSystem is currently paused.")]
127-
public bool isPaused;
128-
129-
[Description("Whether the ParticleSystem is currently emitting.")]
130-
public bool isEmitting;
131-
132-
[Description("Whether the ParticleSystem is currently stopped.")]
133-
public bool isStopped;
134-
135-
[Description("Current particle count.")]
136-
public int particleCount;
137-
138-
[Description("Current simulation time.")]
139-
public float time;
140-
141-
[Description("Main module data.")]
142-
public SerializedMember? main;
143-
144-
[Description("Emission module data.")]
145-
public SerializedMember? emission;
146-
147-
[Description("Shape module data.")]
148-
public SerializedMember? shape;
149-
150-
[Description("Velocity over Lifetime module data.")]
151-
public SerializedMember? velocityOverLifetime;
152-
153-
[Description("Limit Velocity over Lifetime module data.")]
154-
public SerializedMember? limitVelocityOverLifetime;
155-
156-
[Description("Inherit Velocity module data.")]
157-
public SerializedMember? inheritVelocity;
158-
159-
[Description("Lifetime by Emitter Speed module data.")]
160-
public SerializedMember? lifetimeByEmitterSpeed;
161-
162-
[Description("Force over Lifetime module data.")]
163-
public SerializedMember? forceOverLifetime;
164-
165-
[Description("Color over Lifetime module data.")]
166-
public SerializedMember? colorOverLifetime;
167-
168-
[Description("Color by Speed module data.")]
169-
public SerializedMember? colorBySpeed;
170-
171-
[Description("Size over Lifetime module data.")]
172-
public SerializedMember? sizeOverLifetime;
173-
174-
[Description("Size by Speed module data.")]
175-
public SerializedMember? sizeBySpeed;
176-
177-
[Description("Rotation over Lifetime module data.")]
178-
public SerializedMember? rotationOverLifetime;
179-
180-
[Description("Rotation by Speed module data.")]
181-
public SerializedMember? rotationBySpeed;
182-
183-
[Description("External Forces module data.")]
184-
public SerializedMember? externalForces;
185-
186-
[Description("Noise module data.")]
187-
public SerializedMember? noise;
188-
189-
[Description("Collision module data.")]
190-
public SerializedMember? collision;
191-
192-
[Description("Trigger module data.")]
193-
public SerializedMember? trigger;
194-
195-
[Description("Sub Emitters module data.")]
196-
public SerializedMember? subEmitters;
197-
198-
[Description("Texture Sheet Animation module data.")]
199-
public SerializedMember? textureSheetAnimation;
200-
201-
[Description("Lights module data.")]
202-
public SerializedMember? lights;
203-
204-
[Description("Trails module data.")]
205-
public SerializedMember? trails;
206-
207-
[Description("Custom Data module data.")]
208-
public SerializedMember? customData;
209-
210-
[Description("Renderer module data.")]
211-
public SerializedMember? renderer;
212-
}
213-
214-
/// <summary>
215-
/// Response model for Modify ParticleSystem tool.
216-
/// </summary>
217-
[Description("Response containing the result of modifying a ParticleSystem.")]
218-
public class ModifyParticleSystemResponse
219-
{
220-
[Description("Whether the modification was successful.")]
221-
public bool success;
222-
223-
[Description("Reference to the GameObject containing the ParticleSystem component.")]
224-
public GameObjectRef? gameObjectRef;
225-
226-
[Description("Reference to the modified ParticleSystem component.")]
227-
public ComponentRef? componentRef;
228-
229-
[Description("Index of the ParticleSystem component in the GameObject's component list.")]
230-
public int componentIndex = -1;
231-
232-
[Description("Log of modifications made and any warnings/errors encountered.")]
233-
public string[]? logs;
234-
}
235107
}

Unity-Package/Assets/root/Editor/Scripts/Tools/ParticleSystemData.cs.meta renamed to Unity-Package/Assets/root/Editor/Scripts/Data/ParticleSystemData.cs.meta

File renamed without changes.

Unity-Package/Assets/root/Editor/Scripts/Tools/ParticleSystem.Get.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
using com.IvanMurzak.Unity.MCP.Utils;
1919
using Microsoft.Extensions.Logging;
2020

21-
namespace com.IvanMurzak.Unity.MCP.ParticleSystem.Editor.API
21+
namespace com.IvanMurzak.Unity.MCP.ParticleSystem.Editor
2222
{
2323
public partial class Tool_ParticleSystem
2424
{
@@ -121,14 +121,20 @@ public GetParticleSystemResponse Get
121121
bool deepSerialization = false
122122
)
123123
{
124+
if (gameObjectRef == null)
125+
throw new ArgumentNullException(nameof(gameObjectRef));
126+
127+
if (!gameObjectRef.IsValid(out var gameObjectValidationError))
128+
throw new ArgumentException(gameObjectValidationError, nameof(gameObjectRef));
129+
124130
return MainThread.Instance.Run(() =>
125131
{
126132
var go = gameObjectRef.FindGameObject(out var error);
127133
if (error != null)
128134
throw new Exception(error);
129135

130136
if (go == null)
131-
throw new Exception(Error.GameObjectNotFound());
137+
throw new Exception("GameObject not found.");
132138

133139
// Find the ParticleSystem component
134140
UnityEngine.ParticleSystem? ps = null;
@@ -141,7 +147,7 @@ public GetParticleSystemResponse Get
141147
if (comp == null)
142148
continue;
143149

144-
if (componentRef != null && componentRef.IsValid)
150+
if (componentRef != null && componentRef.IsValid(out _))
145151
{
146152
if (componentRef.Matches(allComponents[i], i))
147153
{
@@ -160,7 +166,7 @@ public GetParticleSystemResponse Get
160166
}
161167

162168
if (ps == null)
163-
throw new Exception(Error.ParticleSystemNotFound());
169+
throw new Exception("ParticleSystem component not found on the specified GameObject.");
164170

165171
var response = new GetParticleSystemResponse
166172
{

0 commit comments

Comments
 (0)