質問編集履歴
3
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -365,3 +365,133 @@
|
|
365
365
|
```
|
366
366
|
|
367
367
|
このxにfor文で条件にあったiを代入している感じです。
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
2020/06/07追記
|
372
|
+
|
373
|
+
回答を元に変更してみました。
|
374
|
+
|
375
|
+
CardIDのcardIDの値をエクセルのデータのidに変化させることはできました。(インスペクターで確認)
|
376
|
+
|
377
|
+
しかし、マウスオーバー時の購読がうまく行ってないようです。
|
378
|
+
|
379
|
+
下記に変更した文を記載します。
|
380
|
+
|
381
|
+
```C#
|
382
|
+
|
383
|
+
using UnityEngine;
|
384
|
+
|
385
|
+
using System;
|
386
|
+
|
387
|
+
using UnityEngine.EventSystems;
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
public class CardID : MonoBehaviour, IPointerEnterHandler
|
392
|
+
|
393
|
+
{
|
394
|
+
|
395
|
+
public string cardID ;
|
396
|
+
|
397
|
+
public event Action<string> OnPointerCard;
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
public void OnPointerEnter(PointerEventData eventData)
|
402
|
+
|
403
|
+
{
|
404
|
+
|
405
|
+
OnPointerCard?.Invoke(cardID); // マウスオーバーしたのでカードIDを発火
|
406
|
+
|
407
|
+
}
|
408
|
+
|
409
|
+
}
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
using System.Collections;
|
414
|
+
|
415
|
+
using System.Collections.Generic;
|
416
|
+
|
417
|
+
using UnityEngine;
|
418
|
+
|
419
|
+
using UnityEngine.UI;
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
public class Mouse : MonoBehaviour
|
424
|
+
|
425
|
+
{
|
426
|
+
|
427
|
+
public GameObject CardV;
|
428
|
+
|
429
|
+
public int _cardID;
|
430
|
+
|
431
|
+
string _c;
|
432
|
+
|
433
|
+
void Update()
|
434
|
+
|
435
|
+
{
|
436
|
+
|
437
|
+
// 画面上にあるCardスクリプトを持つオブジェクトを取得
|
438
|
+
|
439
|
+
var allCardInScreen = FindObjectsOfType<CardID>();
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
// マウスオーバーイベントを購読
|
444
|
+
|
445
|
+
foreach (CardID c in allCardInScreen)
|
446
|
+
|
447
|
+
{
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
c.OnPointerCard += cardID => {
|
452
|
+
|
453
|
+
Debug.Log(cardID);//ここでなぜか2が出力される
|
454
|
+
|
455
|
+
if (cardID.Contains("CUU"))
|
456
|
+
|
457
|
+
{
|
458
|
+
|
459
|
+
_c = cardID.Replace("CUU", "");
|
460
|
+
|
461
|
+
int.TryParse(_c, out _cardID);
|
462
|
+
|
463
|
+
_cardID = _cardID - 1;
|
464
|
+
|
465
|
+
CardV.GetComponent<CardView2>().ShowViewU(_cardID);
|
466
|
+
|
467
|
+
}
|
468
|
+
|
469
|
+
};
|
470
|
+
|
471
|
+
}
|
472
|
+
|
473
|
+
}
|
474
|
+
|
475
|
+
}
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
public void UnitSearch(int x)
|
480
|
+
|
481
|
+
{
|
482
|
+
|
483
|
+
CardData.GetComponent<CardD>().ShowDataU(x);
|
484
|
+
|
485
|
+
Obj = Instantiate(CardData, this.transform.position, Quaternion.identity);
|
486
|
+
|
487
|
+
CardID_.GetComponent<CardID>().cardID =unit.Sheet1[x].id;
|
488
|
+
|
489
|
+
Obj.transform.parent = SearchArea.transform;
|
490
|
+
|
491
|
+
}
|
492
|
+
|
493
|
+
```
|
494
|
+
|
495
|
+
MouseでなぜかcardIDが2になってしまっています。
|
496
|
+
|
497
|
+
どうすればCardIDのcardIDになると思いますか?
|
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -316,10 +316,52 @@
|
|
316
316
|
|
317
317
|
}
|
318
318
|
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
319
|
}
|
324
320
|
|
325
321
|
```
|
322
|
+
|
323
|
+
2020/06/05追記
|
324
|
+
|
325
|
+
矢印の部分の表示をするスプリクトの根幹部分(全文はすごく長文になってしまっているので省略)
|
326
|
+
|
327
|
+
```C#
|
328
|
+
|
329
|
+
public void UnitSearch(int x)
|
330
|
+
|
331
|
+
{
|
332
|
+
|
333
|
+
CardData.GetComponent<CardD>().ShowDataU(x);
|
334
|
+
|
335
|
+
Obj = Instantiate(CardData, this.transform.position, Quaternion.identity);
|
336
|
+
|
337
|
+
Obj.transform.parent = SearchArea.transform;
|
338
|
+
|
339
|
+
}
|
340
|
+
|
341
|
+
public void SpelSearch(int x)
|
342
|
+
|
343
|
+
{
|
344
|
+
|
345
|
+
CardData.GetComponent<CardD>().ShowDataS(x);
|
346
|
+
|
347
|
+
Obj = Instantiate(CardData, this.transform.position, Quaternion.identity);
|
348
|
+
|
349
|
+
Obj.transform.parent = SearchArea.transform;
|
350
|
+
|
351
|
+
}
|
352
|
+
|
353
|
+
public void ItemSearch(int x)
|
354
|
+
|
355
|
+
{
|
356
|
+
|
357
|
+
CardData.GetComponent<CardD>().ShowDataI(x);
|
358
|
+
|
359
|
+
Obj = Instantiate(CardData, this.transform.position, Quaternion.identity);
|
360
|
+
|
361
|
+
Obj.transform.parent = SearchArea.transform;
|
362
|
+
|
363
|
+
}
|
364
|
+
|
365
|
+
```
|
366
|
+
|
367
|
+
このxにfor文で条件にあったiを代入している感じです。
|
1
記入漏れ
test
CHANGED
File without changes
|
test
CHANGED
@@ -110,7 +110,7 @@
|
|
110
110
|
|
111
111
|
```
|
112
112
|
|
113
|
-
表示のテンプレート
|
113
|
+
情報表示のテンプレート
|
114
114
|
|
115
115
|
```C#
|
116
116
|
|
@@ -225,3 +225,101 @@
|
|
225
225
|
}
|
226
226
|
|
227
227
|
```
|
228
|
+
|
229
|
+
赤い矢印先のオブジェクトのテンプレート
|
230
|
+
|
231
|
+
```C#
|
232
|
+
|
233
|
+
using System.Collections;
|
234
|
+
|
235
|
+
using System.Collections.Generic;
|
236
|
+
|
237
|
+
using UnityEngine;
|
238
|
+
|
239
|
+
using UnityEngine.UI;
|
240
|
+
|
241
|
+
using System;
|
242
|
+
|
243
|
+
using UnityEngine.EventSystems;
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
public class CardD : MonoBehaviour
|
248
|
+
|
249
|
+
{
|
250
|
+
|
251
|
+
[SerializeField] Image IconImage;
|
252
|
+
|
253
|
+
[SerializeField] Text NameText;
|
254
|
+
|
255
|
+
[SerializeField] Text TypeText;
|
256
|
+
|
257
|
+
[SerializeField] Text KindText;
|
258
|
+
|
259
|
+
[SerializeField] Text LvText;
|
260
|
+
|
261
|
+
[SerializeField] private unit unit;
|
262
|
+
|
263
|
+
[SerializeField] private item item;
|
264
|
+
|
265
|
+
[SerializeField] private spel spel;
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
public void ShowDataU(int x)
|
272
|
+
|
273
|
+
{
|
274
|
+
|
275
|
+
IconImage.sprite = Resources.Load<Sprite>("CardImage/"+ unit.Sheet1[x].id+" "+unit.Sheet1[x].name1);
|
276
|
+
|
277
|
+
NameText.text = unit.Sheet1[x].name1;
|
278
|
+
|
279
|
+
LvText.text = "Lv" + unit.Sheet1[x].level;
|
280
|
+
|
281
|
+
TypeText.text = unit.Sheet1[x].type;
|
282
|
+
|
283
|
+
KindText.text = "ATK/" + unit.Sheet1[x].attack.ToString() + " DEF/" + unit.Sheet1[x].defence.ToString();
|
284
|
+
|
285
|
+
}
|
286
|
+
|
287
|
+
public void ShowDataI(int x)
|
288
|
+
|
289
|
+
{
|
290
|
+
|
291
|
+
IconImage.sprite = Resources.Load<Sprite>("CardImage/" + item.Sheet1[x].id + " " + item.Sheet1[x].name1);
|
292
|
+
|
293
|
+
NameText.text = item.Sheet1[x].name1;
|
294
|
+
|
295
|
+
LvText.text = "Lv" + item.Sheet1[x].level;
|
296
|
+
|
297
|
+
TypeText.text = item.Sheet1[x].type;
|
298
|
+
|
299
|
+
KindText.text = "アイテム|"+item.Sheet1[x].kind+"アイテム";
|
300
|
+
|
301
|
+
}
|
302
|
+
|
303
|
+
public void ShowDataS(int x)
|
304
|
+
|
305
|
+
{
|
306
|
+
|
307
|
+
IconImage.sprite = Resources.Load<Sprite>("CardImage/" + spel.Sheet1[x].id + " " + spel.Sheet1[x].name1);
|
308
|
+
|
309
|
+
NameText.text = spel.Sheet1[x].name1;
|
310
|
+
|
311
|
+
LvText.text = "Lv" + spel.Sheet1[x].level;
|
312
|
+
|
313
|
+
TypeText.text = spel.Sheet1[x].type;
|
314
|
+
|
315
|
+
KindText.text = "スペル|" + spel.Sheet1[x].kind + "スペル";
|
316
|
+
|
317
|
+
}
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
}
|
324
|
+
|
325
|
+
```
|