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

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

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

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

Unity3D

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

Unity

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

Q&A

解決済

1回答

944閲覧

サンプルプログラムを実行した際のUnityエラー

asasqwqw112

総合スコア7

C#

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

Unity3D

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

Unity

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

0グッド

0クリップ

投稿2017/12/08 04:36

###前提・実現したいこと
UnityでMyoという筋電センサアームバンドを動かしたく、https://www.gaprot.jp/pickup/unity-mecanim/unity-chan4
こちらのサイトを参考にして進めていたのですが、
MyoのUnityプラグインの入ったSDKをダウンロードして、
サンプルプログラムを動かそうとした際に以下のエラーメッセージが発生しました。

Unityの知識があまりなく、困惑しております。
よろしくお願いします。

 

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

Assets/Myo Samples/Scripts/ColorBoxByPose.cs(57,26): error CS1061: Type `UnityEngine.Component' does not contain a definition for `material' and no extension method `material' of type `UnityEngine.Component' could be found. Are you missing an assembly reference?
Assets/Myo Samples/Scripts/ColorBoxByPose.cs(53,26): error CS1061: Type `UnityEngine.Component' does not contain a definition for `material' and no extension method `material' of type `UnityEngine.Component' could be found. Are you missing an assembly reference?
Assets/Myo Samples/Scripts/ColorBoxByPose.cs(49,26): error CS1061: Type `UnityEngine.Component' does not contain a definition for `material' and no extension method `material' of type `UnityEngine.Component' could be found. Are you missing an assembly reference?

###該当のソースコード(ColorBoxByPose.cs)

C#

1using UnityEngine; 2using System.Collections; 3 4using LockingPolicy = Thalmic.Myo.LockingPolicy; 5using Pose = Thalmic.Myo.Pose; 6using UnlockType = Thalmic.Myo.UnlockType; 7using VibrationType = Thalmic.Myo.VibrationType; 8 9// Change the material when certain poses are made with the Myo armband. 10// Vibrate the Myo armband when a fist pose is made. 11public class ColorBoxByPose : MonoBehaviour 12{ 13 // Myo game object to connect with. 14 // This object must have a ThalmicMyo script attached. 15 public GameObject myo = null; 16 17 // Materials to change to when poses are made. 18 public Material waveInMaterial; 19 public Material waveOutMaterial; 20 public Material doubleTapMaterial; 21 22 // The pose from the last update. This is used to determine if the pose has changed 23 // so that actions are only performed upon making them rather than every frame during 24 // which they are active. 25 private Pose _lastPose = Pose.Unknown; 26 27 // Update is called once per frame. 28 void Update () 29 { 30 // Access the ThalmicMyo component attached to the Myo game object. 31 ThalmicMyo thalmicMyo = myo.GetComponent<ThalmicMyo> (); 32 33 // Check if the pose has changed since last update. 34 // The ThalmicMyo component of a Myo game object has a pose property that is set to the 35 // currently detected pose (e.g. Pose.Fist for the user making a fist). If no pose is currently 36 // detected, pose will be set to Pose.Rest. If pose detection is unavailable, e.g. because Myo 37 // is not on a user's arm, pose will be set to Pose.Unknown. 38 if (thalmicMyo.pose != _lastPose) { 39 _lastPose = thalmicMyo.pose; 40 41 // Vibrate the Myo armband when a fist is made. 42 if (thalmicMyo.pose == Pose.Fist) { 43 thalmicMyo.Vibrate (VibrationType.Medium); 44 45 ExtendUnlockAndNotifyUserAction (thalmicMyo); 46 47 // Change material when wave in, wave out or double tap poses are made. 48 } else if (thalmicMyo.pose == Pose.WaveIn) { 49 renderer.material = waveInMaterial; 50 51 ExtendUnlockAndNotifyUserAction (thalmicMyo); 52 } else if (thalmicMyo.pose == Pose.WaveOut) { 53 renderer.material = waveOutMaterial; 54 55 ExtendUnlockAndNotifyUserAction (thalmicMyo); 56 } else if (thalmicMyo.pose == Pose.DoubleTap) { 57 renderer.material = doubleTapMaterial; 58 59 ExtendUnlockAndNotifyUserAction (thalmicMyo); 60 } 61 } 62 } 63 64 // Extend the unlock if ThalmcHub's locking policy is standard, and notifies the given myo that a user action was 65 // recognized. 66 void ExtendUnlockAndNotifyUserAction (ThalmicMyo myo) 67 { 68 ThalmicHub hub = ThalmicHub.instance; 69 70 if (hub.lockingPolicy == LockingPolicy.Standard) { 71 myo.Unlock (UnlockType.Timed); 72 } 73 74 myo.NotifyUserAction (); 75 } 76} 77

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

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

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

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

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

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

guest

回答1

0

ベストアンサー

まずエラーコードをそのまま検索してみてください。
参考サイト「Unity 5.6 error UnityEngine.Component' does not contain a definition for materials' and no extension method materials' of type `UnityEngine.Component' could be found. Are you missing an assembly reference? - Unity Answers

古いUnityではコード内で「renderer」と書くだけで、同オブジェクトに付いたRenderer系コンポーネントが取得出来ていました。
現在は仕様変更によりGetComponentメソッドを使う必要があります。

投稿2017/12/09 07:07

編集2017/12/09 07:08
sakura_hana

総合スコア11427

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

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

asasqwqw112

2017/12/11 08:31

こちらを参考に進めたところ解決しました. ありがとうございました!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問