質問編集履歴
1
追加の情報
    
        title	
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        body	
    CHANGED
    
    | 
         @@ -6,6 +6,8 @@ 
     | 
|
| 
       6 
6 
     | 
    
         
             
            ### 発生している問題・エラーメッセージ
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
            最初はオブジェクト参照がオブジェクト インスタンスに設定されていません。というNullがでており、他の方の質問を参考に書き直し下のコードになったのですが新しくエラーが発生してしまいました。
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            **また、このエラーはAを押すと出現します。**
         
     | 
| 
       9 
11 
     | 
    
         
             
            インスタンスの設定をよく理解できていない為単純なミスなのかもしれませんがご教授お願いします。
         
     | 
| 
       10 
12 
     | 
    
         
             
            ```
         
     | 
| 
       11 
13 
     | 
    
         
             
            You are trying to create a MonoBehaviour using the 'new' keyword.  This is not allowed.  MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all
         
     | 
| 
         @@ -45,7 +47,7 @@ 
     | 
|
| 
       45 
47 
     | 
    
         
             
            ```
         
     | 
| 
       46 
48 
     | 
    
         | 
| 
       47 
49 
     | 
    
         
             
            ### 試したこと
         
     | 
| 
       48 
     | 
    
         
            -
            http://portaltan.hatenablog.com/entry/2016/05/24/144108
         
     | 
| 
      
 50 
     | 
    
         
            +
            [http://portaltan.hatenablog.com/entry/2016/05/24/144108](http://portaltan.hatenablog.com/entry/2016/05/24/144108)
         
     | 
| 
       49 
51 
     | 
    
         
             
            こちらのサイトを参考にさせていただきコードを作成しました。
         
     | 
| 
       50 
52 
     | 
    
         
             
            ほかにも Button btn; ⇒ public Button btn;にしてみたりしましたがエラーは起きないのですがオブジェクトを入れることができませんでした。
         
     | 
| 
       51 
53 
     | 
    
         |