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

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

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

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

コンパイル

コンパイルとは、プログラミング言語のテキストソース(ソースコード)をコンピュータ上で実行可能な形式(オブジェクトコード)に変換することをいいます

コンパイルエラー

コンパイルのフェーズで生成されるエラーです。よく無効なシンタックスやタイプが含まれているとき発生します。

Q&A

解決済

1回答

3527閲覧

C# Inputを使うには

JectABC

総合スコア34

C#

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

コンパイル

コンパイルとは、プログラミング言語のテキストソース(ソースコード)をコンピュータ上で実行可能な形式(オブジェクトコード)に変換することをいいます

コンパイルエラー

コンパイルのフェーズで生成されるエラーです。よく無効なシンタックスやタイプが含まれているとき発生します。

0グッド

0クリップ

投稿2017/02/27 06:40

これはInput.locationを使って位置情報を調べるテストコードですが、Inputがどうやら使えないようで、Inputを使うための何か別のライブラリが必要なのでしょうか?

using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Net; using System.Net.Sockets; using System.Text; using System.Threading; //ここだけでは使わないものもimportしています public class Test { public void GetGPS() { // 設定でロケーション機能を有効にしているかどうか調べる if (!Input.location.isEnabledByUser){ break; } // 位置情報取得 Input.location.Start(); //ステータスが Initializing状態の間ループ while (Input.location.status == LocationServiceStatus.Initializing) { //タイムアウト処理 break; } // ユーザがアクセス拒否した状態の処理 if (Input.location.status == LocationServiceStatus.Failed) { Console.Write("ロケーション機能が有効ではありません"); break; }else{ st = Input.location.lastData(); // アクセス成功表示 Console.Write("Location: "+Input.location.lastData.latitude+" "+Input.location.lastData.longitude+" "+Input.location.lastData.altitude+" "+Input.location.lastData.horizontalAccuracy+" "+Input.location.lastData.timestamp); int[] gpsdata; gpsdata = new int[]{Input.location.lastData.latitude,Input.location.lastData.longitude,Input.location.lastData.altitude,Input.location.lastData.horizontalAccuracy,Input.location.lastData.timestamp}; //GPS取得ストップ Input.location.Stop(); } return gpsdata; } }

---環境
unityではなくターミナルで「mcs スクリプトファイル.cs」でコンパイルしています。

---エラー内容
error CS0103: The name `Input' does not exist in the current context

error CS0139: No enclosing loop out of which to break or continue

error CS0103: The name `Input' does not exist in the current context

error CS0103: The name `Input' does not exist in the current context

error CS0103: The name `Input' does not exist in the current context

error CS0139: No enclosing loop out of which to break or continue

error CS0103: The name `Input' does not exist in the current context

error CS0103: The name `st' does not exist in the current context

error CS0103: The name `Input' does not exist in the current context

error CS0103: The name `Input' does not exist in the current context

error CS0103: The name `Input' does not exist in the current context

error CS0103: The name `Input' does not exist in the current context

error CS0103: The name `Input' does not exist in the current context

error CS0103: The name `Input' does not exist in the current context

error CS0103: The name `Input' does not exist in the current context

error CS0103: The name `gpsdata' does not exist in the current context

*if(!Input.location.isEnabledByUser)の行が最初のエラー箇所です。

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

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

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

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

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

guest

回答1

0

ベストアンサー

UnityのInputの話でしたら、.NETFramework内のライブラリではなくUnityEngineライブラリのクラスです。

投稿2017/02/27 07:02

turbgraphics200

総合スコア4267

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

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

JectABC

2017/02/27 13:46

unityではないので、unityEngineは使えないのでしょうか? だとしたらまた別の方法にしなくてはいけませんね...
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問