回答編集履歴
2
新しい問題の発生による質問の切り替え
answer
CHANGED
@@ -1,81 +1,1 @@
|
|
1
|
-
いろいろ試した結果 コードに変更を加えた結果スクリプト上のエラーは解決しました。
|
2
|
-
ですがUNITY上で画像のようなエラーが起きてしまいます
|
3
|
-
|
4
|
-
アイテムの元データ
|
5
|
-
```using System.Collections;
|
6
|
-
using System.Collections.Generic;
|
7
|
-
using UnityEngine;
|
8
|
-
|
1
|
+
更新しましたこのコメントは無視してください
|
9
|
-
|
10
|
-
[CreateAssetMenu(fileName = "Items", menuName = "Items/items")]
|
11
|
-
public class Item : ScriptableObject
|
12
|
-
{
|
13
|
-
[SerializeField]
|
14
|
-
private string itemName;
|
15
|
-
[SerializeField]
|
16
|
-
private Sprite itemImage;
|
17
|
-
[SerializeField]
|
18
|
-
private Text explanation;☆UIのテキスト型にしました
|
19
|
-
|
20
|
-
private EditButton.Symbol EditSymbol;
|
21
|
-
|
22
|
-
public string MyItemName { get => itemName;}
|
23
|
-
public Sprite MyItemImage { get => itemImage;}
|
24
|
-
public Text MyExplanation { get => explanation;}
|
25
|
-
}
|
26
|
-
|
27
|
-
```
|
28
|
-
実際に変数内のテキストを変更する関数スクリプト
|
29
|
-
```
|
30
|
-
using System.Collections;
|
31
|
-
using System.Collections.Generic;
|
32
|
-
#if UNITY_EDITOR
|
33
|
-
using UnityEngine;
|
34
|
-
using UnityEngine.UI;
|
35
|
-
|
36
|
-
public class ExplanationTXT : MonoBehaviour
|
37
|
-
{
|
38
|
-
private Item item;
|
39
|
-
private GameObject ChangeTXT = null;
|
40
|
-
public Item MyItem { get => item; private set => item = value; }
|
41
|
-
|
42
|
-
public void SetExplanation(Text etext)
|
43
|
-
{
|
44
|
-
Text ChangeTXT = MyItem.MyExplanation;
|
45
|
-
}
|
46
|
-
}
|
47
|
-
#endif
|
48
|
-
```
|
49
|
-
クラスを呼び出すタイミング
|
50
|
-
```using System.Collections;
|
51
|
-
using System.Collections.Generic;
|
52
|
-
using UnityEngine;
|
53
|
-
using UnityEngine.EventSystems;
|
54
|
-
using UnityEngine.UI;
|
55
|
-
|
56
|
-
public class EditSlot : Slot
|
57
|
-
{
|
58
|
-
private Edit edit;
|
59
|
-
private Text text;
|
60
|
-
private ExplanationTXT explanationTXT;
|
61
|
-
public Edit MyEdit { get => edit; private set => edit = value; }
|
62
|
-
public Text Text { get => text; private set => text = value; }
|
63
|
-
public ExplanationTXT ExplanationTXT { get => explanationTXT; private set => explanationTXT = value; }
|
64
|
-
|
65
|
-
protected override void Start()
|
66
|
-
{
|
67
|
-
base.Start();//継承元のスタート関数
|
68
|
-
|
69
|
-
MyEdit = FindObjectOfType<Edit>();
|
70
|
-
|
71
|
-
}
|
72
|
-
|
73
|
-
public override void OnDrop(PointerEventData eventData)
|
74
|
-
{
|
75
|
-
base.OnDrop(eventData);
|
76
|
-
edit.SetItem(MyItem);
|
77
|
-
ExplanationTXT.SetExplanation(Text);
|
78
|
-
}
|
79
|
-
|
80
|
-
}
|
81
|
-
```
|
1
コードの変更と新たなエラーい
answer
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
いろいろ試した結果 コードに変更を加えました。
|
1
|
+
いろいろ試した結果 コードに変更を加えた結果スクリプト上のエラーは解決しました。
|
2
|
+
ですがUNITY上で画像のようなエラーが起きてしまいます
|
2
3
|
|
3
|
-
|
4
|
+
アイテムの元データ
|
4
5
|
```using System.Collections;
|
5
6
|
using System.Collections.Generic;
|
6
7
|
using UnityEngine;
|
@@ -55,9 +56,11 @@
|
|
55
56
|
public class EditSlot : Slot
|
56
57
|
{
|
57
58
|
private Edit edit;
|
58
|
-
|
59
|
+
private Text text;
|
59
60
|
private ExplanationTXT explanationTXT;
|
60
61
|
public Edit MyEdit { get => edit; private set => edit = value; }
|
62
|
+
public Text Text { get => text; private set => text = value; }
|
63
|
+
public ExplanationTXT ExplanationTXT { get => explanationTXT; private set => explanationTXT = value; }
|
61
64
|
|
62
65
|
protected override void Start()
|
63
66
|
{
|
@@ -71,9 +74,8 @@
|
|
71
74
|
{
|
72
75
|
base.OnDrop(eventData);
|
73
76
|
edit.SetItem(MyItem);
|
74
|
-
ExplanationTXT.SetExplanation();
|
77
|
+
ExplanationTXT.SetExplanation(Text);
|
75
78
|
}
|
76
79
|
|
77
80
|
}
|
78
|
-
|
79
|
-
```
|