@@ -43,39 +43,24 @@ static DanmakuPrefab() {
43
43
hiddenParticle . axisOfRotation = Vector3 . forward ;
44
44
}
45
45
46
+
47
+
46
48
[ SerializeField ]
47
49
private IDanmakuController [ ] extraControllers ;
48
- internal IDanmakuController [ ] ExtraControllers {
50
+
51
+ private DanmakuController controllerAggregate ;
52
+
53
+ internal DanmakuController ExtraControllers {
49
54
get {
50
- return extraControllers ;
55
+ return controllerAggregate ;
51
56
}
52
57
}
53
58
54
59
public void Add ( Danmaku danmaku ) {
55
- // Debug.Log("Add");
56
- // if (currentDanmaku == null) {
57
- // currentDanmaku = new Danmaku[128];
58
- // }
59
- // danmakuCount++;
60
- // if (danmakuCount >= currentDanmaku.Length) {
61
- // Danmaku[] temp = new Danmaku[Mathf.NextPowerOfTwo(danmakuCount + 1)];
62
- // System.Array.Copy(currentDanmaku, temp, currentDanmaku.Length);
63
- // currentDanmaku = temp;
64
- // }
65
- // danmaku.renderIndex = danmakuCount;
66
- // currentDanmaku [danmakuCount] = danmaku;
67
60
currentDanmaku . Add ( danmaku ) ;
68
61
}
69
62
70
63
public void Remove ( Danmaku danmaku ) {
71
- // Debug.Log("remove");
72
- // int deadIndex = danmaku.poolIndex;;
73
- // Danmaku temp = currentDanmaku [danmakuCount];
74
- // currentDanmaku [danmakuCount] = danmaku;
75
- // currentDanmaku [deadIndex] = temp;
76
- // danmaku.renderIndex = danmakuCount;
77
- // danmaku.renderIndex = deadIndex;
78
- // danmakuCount--;
79
64
currentDanmaku . Remove ( danmaku ) ;
80
65
}
81
66
@@ -94,9 +79,7 @@ void Update() {
94
79
}
95
80
96
81
int count2 = runtimeSystem . GetParticles ( particles ) ;
97
- // if(count > count2) {
98
- // Debug.Log(count + ", " + count2);
99
- // }
82
+ Debug . Log ( count2 ) ;
100
83
Vector3 forward = Vector3 . forward ;
101
84
bool done ;
102
85
IEnumerator < Danmaku > enumerator = currentDanmaku . GetEnumerator ( ) ;
@@ -165,18 +148,16 @@ void Update() {
165
148
}
166
149
}
167
150
}
168
-
169
- // for(; index < count; index++) {
170
- // particles[index].lifetime = 10000;
171
- // particles[index].position = Vector2.up * 20;
172
- // particles[index].size = 0f;
173
- // }
174
151
runtimeSystem . SetParticles ( particles , danmakuCount ) ;
175
152
}
176
153
177
154
public override void Awake ( ) {
178
155
base . Awake ( ) ;
179
156
157
+ for ( int i = 0 ; i < extraControllers . Length ; i ++ ) {
158
+ controllerAggregate += extraControllers [ i ] . UpdateDanmaku ;
159
+ }
160
+
180
161
GetComponent < SpriteRenderer > ( ) . enabled = false ;
181
162
GetComponent < CircleCollider2D > ( ) . enabled = false ;
182
163
@@ -203,14 +184,15 @@ public override void Awake() {
203
184
runtimeSystem . gravityModifier = 0f ;
204
185
runtimeSystem . startSpeed = 0f ;
205
186
runtimeSystem . enableEmission = false ;
206
-
207
- runtimeSystem . Emit ( runtimeSystem . maxParticles ) ;
208
187
209
188
particles = new ParticleSystem . Particle [ runtimeSystem . particleCount ] ;
210
189
211
190
Material renderMaterial = new Material ( Material ) ;
212
191
renderMaterial . mainTexture = Sprite . texture ;
213
192
193
+ MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock ( ) ;
194
+ propertyBlock . AddTexture ( "_MainTex" , Sprite . texture ) ;
195
+
214
196
if ( useMesh ) {
215
197
spriteMesh = new Mesh ( ) ;
216
198
@@ -241,6 +223,7 @@ public override void Awake() {
241
223
runtimeRenderer . renderMode = ParticleSystemRenderMode . Billboard ;
242
224
}
243
225
runtimeRenderer . sharedMaterial = renderMaterial ;
226
+ runtimeRenderer . SetPropertyBlock ( propertyBlock ) ;
244
227
runtimeRenderer . sortingLayerID = cachedSortingLayer ;
245
228
runtimeRenderer . sortingOrder = cachedSortingOrder ;
246
229
runtimeRenderer . reflectionProbeUsage = UnityEngine . Rendering . ReflectionProbeUsage . Off ;
0 commit comments