質問編集履歴
4
修正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
ソシャゲのように属性限定のガチャを作りたい
|
body
CHANGED
File without changes
|
3
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -76,6 +76,6 @@
|
|
76
76
|
|
77
77
|
public void Gacha100()
|
78
78
|
{
|
79
|
-
GameObject GachaItem =
|
79
|
+
GameObject GachaItem = All[Random.Range(0,99)];
|
80
80
|
Instantiate(GachaItem, new Vector2(0,0), Quaternion.identity);
|
81
81
|
}
|
2
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -68,7 +68,14 @@
|
|
68
68
|
|
69
69
|
###したいこと
|
70
70
|
この1000のオブジェクトが入ったリストを元に
|
71
|
-
Element0からElement99まで指定して1つオブジェクトを取り出したり、
|
71
|
+
Element0からElement99まで指定して1つオブジェクトを取り出したりはできるようになったのですが、
|
72
|
-
Elementに設定されたZokuseiの内容で絞り込み、その中から1つ取り出す
|
72
|
+
Elementに設定されたZokuseiの内容で絞り込み、その中から1つ取り出すにはどうすればいいでしょうか?
|
73
73
|
|
74
|
+
###ガチャのスクリプト
|
74
|
-
|
75
|
+
//これは1-100のガチャです
|
76
|
+
|
77
|
+
public void Gacha100()
|
78
|
+
{
|
79
|
+
GameObject GachaItem = itemPrefabs[Random.Range(0,99)];
|
80
|
+
Instantiate(GachaItem, new Vector2(0,0), Quaternion.identity);
|
81
|
+
}
|
1
追記
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
リストを作成してソシャゲのようにガチャを作りたい
|
body
CHANGED
@@ -1,10 +1,74 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
|
3
|
-
ソシャゲのようにガチャ機能と図鑑機能があるアプリを開発中です。
|
4
|
-
|
5
|
-
キャラクターごとに図鑑番号や属性を設定して、
|
3
|
+
キャラクターごとに図鑑番号や属性を設定して、
|
6
4
|
図鑑番号1−100のガチャや
|
7
5
|
火属性限定ガチャなどを作りたいです。
|
8
6
|
|
9
7
|
リストをどう使えば活用すればいいか分からない為
|
10
|
-
参照すべきサイトとかあれば教えていただきたいです。
|
8
|
+
参照すべきサイトとかあれば教えていただきたいです。
|
9
|
+
|
10
|
+
###追記↓
|
11
|
+
修正前の質問はさすがに抽象的すぎました。申し訳ありません。
|
12
|
+
1000キャラ分のオブジェクトがあり、キャラ用スクリプトがアタッチされていて、
|
13
|
+
インスペクタタブで情報を書き込めるようになっています。
|
14
|
+
|
15
|
+
それと、リスト用の別スクリプトを作成した上で空のオブジェクトにアタッチした状態です。
|
16
|
+
|
17
|
+
※図鑑を作りたい ガチャを作りたいの2つが混同していたので今回はガチャのみの質問とさせていただきます。
|
18
|
+
###キャラ用スクリプト
|
19
|
+
using System.Collections;
|
20
|
+
using System.Collections.Generic;
|
21
|
+
using UnityEngine;
|
22
|
+
using UnityEngine.UI;
|
23
|
+
|
24
|
+
public class Book : MonoBehaviour
|
25
|
+
{
|
26
|
+
|
27
|
+
public Text Name;
|
28
|
+
public string nam;
|
29
|
+
|
30
|
+
public Image Image;
|
31
|
+
public Text Sex;
|
32
|
+
public string sex;
|
33
|
+
public Text Age;
|
34
|
+
public string age;
|
35
|
+
public Text Introduce;
|
36
|
+
public string introduce;
|
37
|
+
public Text Zokusei;
|
38
|
+
public string zokusei;
|
39
|
+
|
40
|
+
// Start is called before the first frame update
|
41
|
+
void Start()
|
42
|
+
{
|
43
|
+
Name.text = nam;
|
44
|
+
Sex.text = sex;
|
45
|
+
Age.text = age;
|
46
|
+
Introduce.text = introduce;
|
47
|
+
Zokusei.text = Zokusei;
|
48
|
+
}
|
49
|
+
|
50
|
+
// Update is called once per frame
|
51
|
+
void Update()
|
52
|
+
{
|
53
|
+
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
###リスト用スクリプト
|
59
|
+
using System.Collections;
|
60
|
+
using System.Collections.Generic;
|
61
|
+
using UnityEngine;
|
62
|
+
using UnityEngine.UI;
|
63
|
+
|
64
|
+
public class List : MonoBehaviour
|
65
|
+
{
|
66
|
+
|
67
|
+
public GameObject[] All;
|
68
|
+
|
69
|
+
###したいこと
|
70
|
+
この1000のオブジェクトが入ったリストを元に
|
71
|
+
Element0からElement99まで指定して1つオブジェクトを取り出したり、
|
72
|
+
Elementに設定されたZokuseiの内容で絞り込み、その中から1つ取り出す
|
73
|
+
|
74
|
+
といったことをするにはどうすればいいでしょうか?
|