知りたいこと
生成「される」側のオブジェクトのパラメータを生成「する」側で取得したい場合を知りたい。
c#
1 using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class tst : MonoBehaviour { 6 7 public int Parametor; 8 public GameObject ttobj; 9 public tt tt; 10 11 // Use this for initialization 12 void Start () { 13 14 } 15 16 // Update is called once per frame 17 void Update () { 18 if(Input.GetKeyDown(KeyCode.Space)) 19 { 20 Parametor += tt.point; 21 22 Instantiate(ttobj, transform.position, Quaternion.identity); 23 } 24 } 25} 26
例ではこのような感じで、生成時にtt
スクリプトのパラメータを取得しようとしています。(なお、ttobjにもtt
スクリプトをAddComponentしています。)
ですが、生成処理のみ通っており、Parametor変数への変化がありませんでした。
取得の方法があれば、参考までにご教授していたできたいです・・・。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。