GameObject obj = Instantiate(Resources.Load("HogePrefab"));
だとエラーになるので、
GameObject obj = Instantiate(Resources.Load("HogePrefab")) as GameObject;
とか
GameObject obj = (GameObject)Instantiate(Resources.Load("HogePrefab"));
でキャストがだるい!
URL:http://docs.unity3d.com/Documentation/ScriptReference/Object.Instantiate.html
↑の公式ドキュメントに
static function Instantiate.<T> (original : T) : T
なんて書いてた。
ジェネリックス使っても面倒かもしれないけど、こう書いたが、
GameObject obj = Instantiate<GameObject>(Resources.Load("HogePrefab"));
とか、Resourcesのロードの箇所にタイプ指定しても効果なし、
GameObject obj = Instantiate<GameObject>(Resources.Load("HogePrefab", typeof(GameObject)));
↓のエラーが出てしまう・・・。
error CS0308: The non-generic method `UnityEngine.Object.Instantiate(UnityEngine.Object)' cannot be used with the type arguments
ジェネリックスの読み方間違ってるのと思ったけど、
http://docs.unity3d.com/Documentation/Manual/GenericFunctions.html
こちらを見るかぎり間違ってなさそう。
こちらにもtypoじゃないのか?の指摘あった。
http://answers.unity3d.com/questions/60275/objectinstantiatet-really.html