プレハブにこんな感じのスクリプトを作成して、プレハブのオブジェクトにアタッチ。
public void Create(Farm farm)
{
farmData = farm;
}
プレハブの使用元ではこんな感じでパラメータを渡せる。
GameObject farm = Instantiate(prefabObj, new Vector3(xPosition, yStartPosition - yPositionInterval * count , 0), Quaternion.identity);
var c = farm.GetComponentInChildren<FarmTouchController>();
c.Create(f);
GetComponentInChildren<>を使用するのがポイントだと思う。
この動作が決まったときはガッツポーズしてしまったよ。
