{"action":"created","issue":{"url":"https://api.github.com/repos/modesttree/Zenject/issues/47","labels_url":"https://api.github.com/repos/modesttree/Zenject/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/modesttree/Zenject/issues/47/comments","events_url":"https://api.github.com/repos/modesttree/Zenject/issues/47/events","html_url":"https://github.com/modesttree/Zenject/pull/47","id":103069284,"number":47,"title":"Update GameObjectFactory.cs","user":{"login":"zeljkokalezic","id":9953216,"avatar_url":"https://avatars.githubusercontent.com/u/9953216?v=3","gravatar_id":"","url":"https://api.github.com/users/zeljkokalezic","html_url":"https://github.com/zeljkokalezic","followers_url":"https://api.github.com/users/zeljkokalezic/followers","following_url":"https://api.github.com/users/zeljkokalezic/following{/other_user}","gists_url":"https://api.github.com/users/zeljkokalezic/gists{/gist_id}","starred_url":"https://api.github.com/users/zeljkokalezic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zeljkokalezic/subscriptions","organizations_url":"https://api.github.com/users/zeljkokalezic/orgs","repos_url":"https://api.github.com/users/zeljkokalezic/repos","events_url":"https://api.github.com/users/zeljkokalezic/events{/privacy}","received_events_url":"https://api.github.com/users/zeljkokalezic/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-25T16:45:37Z","updated_at":"2015-08-26T04:19:51Z","closed_at":"2015-08-26T04:19:51Z","pull_request":{"url":"https://api.github.com/repos/modesttree/Zenject/pulls/47","html_url":"https://github.com/modesttree/Zenject/pull/47","diff_url":"https://github.com/modesttree/Zenject/pull/47.diff","patch_url":"https://github.com/modesttree/Zenject/pull/47.patch"},"body":"Added ability to game object factory to instantiate game objects from prefab or from resource, not just from default prefab bound in the installer.\r\n\r\nUsage example in hypothetical Asteroid spawner:\r\n\r\n[Inject]\r\nprivate EnemyPresenter.Factory enemyPresenterFactory;\r\n//asteroid prefabs with different 3D models\r\npublic GameObject[] asteroids;\r\n\r\n...\r\n\r\nvar randomNumber = UnityEngine.Random.Range(0, asteroids.Length);\r\nGameObject asteroid = asteroids[randomNumber];\r\nenemyPresenterFactory.Create(asteroid);"},"comment":{"url":"https://api.github.com/repos/modesttree/Zenject/issues/comments/134824536","html_url":"https://github.com/modesttree/Zenject/pull/47#issuecomment-134824536","issue_url":"https://api.github.com/repos/modesttree/Zenject/issues/47","id":134824536,"user":{"login":"svermeulen","id":810762,"avatar_url":"https://avatars.githubusercontent.com/u/810762?v=3","gravatar_id":"","url":"https://api.github.com/users/svermeulen","html_url":"https://github.com/svermeulen","followers_url":"https://api.github.com/users/svermeulen/followers","following_url":"https://api.github.com/users/svermeulen/following{/other_user}","gists_url":"https://api.github.com/users/svermeulen/gists{/gist_id}","starred_url":"https://api.github.com/users/svermeulen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svermeulen/subscriptions","organizations_url":"https://api.github.com/users/svermeulen/orgs","repos_url":"https://api.github.com/users/svermeulen/repos","events_url":"https://api.github.com/users/svermeulen/events{/privacy}","received_events_url":"https://api.github.com/users/svermeulen/received_events","type":"User","site_admin":false},"created_at":"2015-08-26T04:19:51Z","updated_at":"2015-08-26T04:19:51Z","body":"Hi - thanks for the pull request  :)\r\n\r\nBut I would argue that this is improper usage of the `GameObjectFactory` class.  For a case like your example, I would suggest creating a custom factory instead, to handle the random prefab selection.  So it would then call `_container.InstantiatePrefabForComponent` directly.  \r\n\r\nSee the section of the readme on custom factories [here](https://github.com/modesttree/Zenject#custom-factories).  Also, [here](https://www.reddit.com/r/Zenject/comments/3brroe/questionsimple_ftg_with_mvc_pattern/) is a good real-world example of using them.\r\n\r\nAnother option, if the prefab changes, is to use an abstract factory (IFactory<>), which you can also find documented on the README"}}