質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
C#

C#はマルチパラダイムプログラミング言語の1つで、命令形・宣言型・関数型・ジェネリック型・コンポーネント指向・オブジェクティブ指向のプログラミング開発すべてに対応しています。

Unity3D

Unity3Dは、ゲームや対話式の3Dアプリケーション、トレーニングシュミレーション、そして医学的・建築学的な技術を可視化する、商業用の開発プラットフォームです。

Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

Q&A

0回答

508閲覧

【Unity5】ビルド時にだけCS1061エラーが発生する

leonarudo00

総合スコア13

C#

C#はマルチパラダイムプログラミング言語の1つで、命令形・宣言型・関数型・ジェネリック型・コンポーネント指向・オブジェクティブ指向のプログラミング開発すべてに対応しています。

Unity3D

Unity3Dは、ゲームや対話式の3Dアプリケーション、トレーニングシュミレーション、そして医学的・建築学的な技術を可視化する、商業用の開発プラットフォームです。

Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

0グッド

1クリップ

投稿2017/12/19 06:48

###前提・実現したいこと
こちらのUnityプロジェクトをビルドしたい。

###発生している問題・エラーメッセージ

Assets\ThetaStreaming\ThetaWifiStreaming.cs(37,11): error CS1061: 'WebRequest' does not contain a definition for 'Timeout' and no extension method 'Timeout' accepting a first argument of type 'WebRequest' could be found (are you missing a using directive or an assembly reference?) Assets\ThetaStreaming\ThetaWifiStreaming.cs(40,31): error CS0117: 'Encoding' does not contain a definition for 'Default' Assets\ThetaStreaming\ThetaWifiStreaming.cs(46,11): error CS1061: 'WebRequest' does not contain a definition for 'ContentLength' and no extension method 'ContentLength' accepting a first argument of type 'WebRequest' could be found (are you missing a using directive or an assembly reference?) Assets\ThetaStreaming\ThetaWifiStreaming.cs(51,30): error CS1061: 'WebRequest' does not contain a definition for 'GetRequestStream' and no extension method 'GetRequestStream' accepting a first argument of type 'WebRequest' could be found (are you missing a using directive or an assembly reference?) Assets\ThetaStreaming\ThetaWifiStreaming.cs(53,13): error CS1061: 'Stream' does not contain a definition for 'Close' and no extension method 'Close' accepting a first argument of type 'Stream' could be found (are you missing a using directive or an assembly reference?) Assets\ThetaStreaming\ThetaWifiStreaming.cs(54,27): error CS1061: 'WebRequest' does not contain a definition for 'GetResponse' and no extension method 'GetResponse' accepting a first argument of type 'WebRequest' could be found (are you missing a using directive or an assembly reference?) Assets\ThetaStreaming\ThetaWifiStreaming.cs(57,47): error CS0246: The type or namespace name 'BufferedStream' could not be found (are you missing a using directive or an assembly reference?) Assets\ThetaStreaming\ThetaWifiStreaming.cs(102,31): error CS0117: 'Encoding' does not contain a definition for 'Default' Error building Player because scripts had compiler errors

###該当のソースコード

csharp

1using UnityEngine; 2using System.Collections; 3using System.Net; 4using System.IO; 5using System.Text; 6using System.Collections; 7using System.Collections.Generic; 8using LitJson; 9 10public class ThetaWifiStreaming : MonoBehaviour { 11 12 private bool isLooping = true; 13 private Renderer myRenderer; 14 public string thetaUrl = "http://192.168.1.1:80"; 15 private string executeCmd = "/osc/commands/execute"; 16 public JsonData outputJson = new JsonData(); 17 18 // Use this for initialization 19 IEnumerator Start () { 20 string jsonStr; 21 myRenderer = GetComponent<Renderer>(); 22 23 jsonStr = "{" + 24 "\"name\" : \"camera.startSession\", " + 25 "\"parameters\": {} " + 26 "}"; 27 yield return StartCoroutine( SendThetaCmd( jsonStr ) ); 28 print( outputJson["results"]["sessionId"] ); 29 string sessionId = (string)(outputJson["results"]["sessionId"]); 30 31 string url = thetaUrl + executeCmd; 32 var request = HttpWebRequest.Create (url); 33 HttpWebResponse response = null; 34 request.Method = "POST"; 35 request.Timeout = (int)(30 * 10000f); 36 request.ContentType = "application/json;charset=utf-8"; 37 38 byte[] postBytes = Encoding.Default.GetBytes ("{" + 39 "\"name\": \"camera._getLivePreview\"," + 40 "\"parameters\": { " + 41 "\"sessionId\": \"" + sessionId +"\"" + 42 "}" + 43 "}"); 44 request.ContentLength = postBytes.Length; 45 46 Stream reqStream = request.GetRequestStream (); 47 reqStream.Write (postBytes, 0, postBytes.Length); 48 reqStream.Close (); 49 Stream stream = request.GetResponse ().GetResponseStream (); 50 51 BinaryReader reader = new BinaryReader (new BufferedStream (stream), new System.Text.ASCIIEncoding ()); 52 53 List<byte> imageBytes = new List<byte> (); 54 bool isLoadStart = false; 55 while( isLooping ) { 56 byte byteData1 = reader.ReadByte (); 57 byte byteData2 = reader.ReadByte (); 58 59 if (!isLoadStart) { 60 if (byteData1 == 0xFF && byteData2 == 0xD8){ 61 // mjpeg start! ( [0xFF 0xD8 ... ) 62 imageBytes.Add(byteData1); 63 imageBytes.Add(byteData2); 64 65 isLoadStart = true; 66 } 67 } else { 68 imageBytes.Add(byteData1); 69 imageBytes.Add(byteData2); 70 71 if (byteData1 == 0xFF && byteData2 == 0xD9){ 72 // mjpeg end (... 0xFF 0xD9] ) 73 74 Texture2D tex = new Texture2D(2, 2); 75 tex.LoadImage ((byte[])imageBytes.ToArray ()); 76 myRenderer.material.mainTexture = tex; 77 imageBytes.Clear(); 78 yield return null; 79 isLoadStart = false; 80 } 81 } 82 } 83 } 84 85 public IEnumerator SendThetaCmd ( string inputJsonText ) { 86 87 Dictionary<string, string> header = new Dictionary<string, string> (); 88 header.Add ("Content-Type", "application/json; charset=UTF-8"); 89 90 byte[] postBytes = Encoding.Default.GetBytes (inputJsonText); 91 92 string url = thetaUrl + executeCmd; 93 WWW myWww = new WWW (url, postBytes, header); 94 yield return myWww; 95 96 if (myWww.error == null) { 97 Debug.Log("Success"); 98 outputJson = JsonMapper.ToObject( myWww.text ); 99 print( myWww.text ); 100 } 101 else{ 102 Debug.Log("Failure"); 103 } 104 } 105 // Update is called once per frame 106 void Update () { 107 if ( Input.GetKey(KeyCode.Escape) ) { 108 isLooping = false; 109 } 110 } 111}

###試したこと
0. ThetaWifiStreamingDemoシーンの動作確認->上記のソースコード含め全て正常に動作することを確認
0. BuildSettingでPlatformをWindowsStoreに切り替え、Unity C# Projectsにチェック(後にHololensへのビルドを考えているためこのようにしています)
0. Buildボタンを押し、Appフォルダを新規作成しその中にビルド->その後問題のエラーが発生

###補足情報(言語/FW/ツール等のバージョンなど)
Unity 5.6.4f

エディタ上では動作し、スクリプトでも名前空間の参照もできてるようなのですが、なぜかCS1061エラーがでてしまいます。
分かる方いらっしゃいましたら、よろしくお願いいたします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問