4
4
using UnityEngine ;
5
5
using UnityEngine . Events ;
6
6
using System ;
7
+ using System . Linq ;
7
8
8
9
namespace Fungus
9
10
{
@@ -120,6 +121,7 @@ public class ClickableCharacter : Command
120
121
121
122
[ Tooltip ( "List of methods to call. Supports methods with one string parameter." ) ]
122
123
[ SerializeField ] protected StringEvent stringEvent2 = new StringEvent ( ) ;
124
+ protected string myGoGo = "" ;
123
125
protected Stage stage ;
124
126
protected virtual void DoInvoke ( )
125
127
{
@@ -179,9 +181,10 @@ protected void CastRay()
179
181
{
180
182
Ray ray = mainCam . ScreenPointToRay ( Input . mousePosition ) ;
181
183
RaycastHit2D hit = Physics2D . Raycast ( ray . origin , ray . direction , Mathf . Infinity ) ;
184
+
182
185
if ( hit )
183
186
{
184
- if ( hit . collider . gameObject . name == character . name )
187
+ if ( hit . collider . gameObject . name == myGoGo )
185
188
{
186
189
if ( enableDebugLog )
187
190
{
@@ -191,11 +194,11 @@ protected void CastRay()
191
194
//Invoke starts here!
192
195
if ( Mathf . Approximately ( delay , 0f ) )
193
196
{
194
- DoInvoke ( ) ;
197
+ this . DoInvoke ( ) ;
195
198
}
196
199
else
197
200
{
198
- Invoke ( "DoInvoke" , delay ) ;
201
+ this . Invoke ( "DoInvoke" , delay ) ;
199
202
}
200
203
}
201
204
}
@@ -240,14 +243,16 @@ protected void UpdateColliderPosition()
240
243
241
244
}
242
245
*/
246
+ private static int indexNum = 0 ;
243
247
protected void AddCollider ( )
244
248
{
245
249
if ( character != null && mainCam != null )
246
250
{
247
251
BoxCollider2D boxy ;
248
252
float rectX = character . State . portraitImage . rectTransform . sizeDelta . x ;
249
253
float rectY = character . State . portraitImage . rectTransform . sizeDelta . y ;
250
- GameObject myGO = new GameObject ( character . name ) ;
254
+ GameObject myGO = new GameObject ( character . name + "_" + indexNum ++ ) ;
255
+ myGoGo = myGO . name ;
251
256
myGO . AddComponent < BoxCollider2D > ( ) ;
252
257
boxy = myGO . GetComponent < BoxCollider2D > ( ) ;
253
258
boxy . transform . SetParent ( character . transform , false ) ;
@@ -349,6 +354,7 @@ public override string GetSummary()
349
354
}
350
355
public override void OnEnter ( )
351
356
{
357
+
352
358
353
359
//Force 1st frame update
354
360
Canvas . ForceUpdateCanvases ( ) ;
0 commit comments