[過去ログ]
【ゲームエンジン】Unityなんでも質問スレpart12 (1002レス)
【ゲームエンジン】Unityなんでも質問スレpart12 http://mevius.5ch.net/test/read.cgi/gamedev/1699257023/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
必死チェッカー(本家)
(べ)
自ID
レス栞
あぼーん
このスレッドは過去ログ倉庫に格納されています。
次スレ検索
歴削→次スレ
栞削→次スレ
過去ログメニュー
544: 名前は開発中のものです。 [sage] 2023/12/08(金) 00:30:17.07 ID:NwGBSXPg public static GameObject MyInstantiate (this GameObject original, Vector3 position, Quaternion rotation, MonoBehaviour targetComponent, int val) { GameObject instantiatedObject = GameObject.Instantiate (original, position, rotation); // 指定されたコンポーネントが存在するか確認 MonoBehaviour[] components = instantiatedObject.GetComponents<MonoBehaviour> (); foreach (MonoBehaviour component in components) { if (component != null && component.GetType () == targetComponent.GetType ()) { // Int型のpublic変数があるか確認 System.Reflection.FieldInfo intField = component.GetType ().GetField ("MyInt"); if (intField != null && intField.FieldType == typeof (int)) intField.SetValue (component, val); } } return instantiatedObject; } MyInstantiate( myGameObject ,Vector3.back ,Quaternion.identity, new TestCompo() , 4); Instantiate変数入力込の一行書きはこんな感じ。実用的かはわからん。 http://mevius.5ch.net/test/read.cgi/gamedev/1699257023/544
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.028s