質問編集履歴

3

原因がわかった

2017/03/14 12:33

投稿

mantohihi
mantohihi

スコア115

test CHANGED
File without changes
test CHANGED
@@ -75,3 +75,21 @@
75
75
  InvalidCastException: Cannot cast from source type to destination type.
76
76
 
77
77
  Scene01GameObject.Start () (at Assets/Scene/Scene01GameObject.cs:34)
78
+
79
+
80
+
81
+ ---
82
+
83
+ いま、原因がわかりました。
84
+
85
+
86
+
87
+ Panelの名前は ErrMsgPanel にしていたのですが、それに付随していたC#コードのファイル名も ErrMsgPanel で、おなじリソースフォルダにいれていたのが原因でした。
88
+
89
+
90
+
91
+ 全く別のPanelを新しく作成して試したらうまくいったので気がつきました。
92
+
93
+
94
+
95
+ すごく簡単なミスでした。恥ずかしいです。

2

エラーメッセージ追加

2017/03/14 12:33

投稿

mantohihi
mantohihi

スコア115

test CHANGED
File without changes
test CHANGED
@@ -65,3 +65,13 @@
65
65
 
66
66
 
67
67
  これでもだめかー なんでだろう、、、
68
+
69
+
70
+
71
+ エラーメッセージは以下の感じです
72
+
73
+
74
+
75
+ InvalidCastException: Cannot cast from source type to destination type.
76
+
77
+ Scene01GameObject.Start () (at Assets/Scene/Scene01GameObject.cs:34)

1

コード追加

2017/03/14 12:28

投稿

mantohihi
mantohihi

スコア115

test CHANGED
File without changes
test CHANGED
@@ -51,3 +51,17 @@
51
51
 
52
52
 
53
53
  構造はこのようにしたいのですが、可能でしょうか?
54
+
55
+
56
+
57
+ ```C#
58
+
59
+ GameObject ErrMsgPanel = (GameObject)Instantiate(Resources.Load("PrefabMsgPanel/ErrMsgPanel"));
60
+
61
+ ErrMsgPanel.transform.SetParent ( MainPanl.transform, false );
62
+
63
+ ```
64
+
65
+
66
+
67
+ これでもだめかー なんでだろう、、、