{"id":12,"date":"2026-07-30T20:14:42","date_gmt":"2026-07-30T20:14:42","guid":{"rendered":"https:\/\/gamecodeur.animapix.fr\/?p=12"},"modified":"2026-07-30T20:14:42","modified_gmt":"2026-07-30T20:14:42","slug":"unity-prefabs-projet-propre","status":"publish","type":"post","link":"https:\/\/gamecodeur.animapix.fr\/?p=12","title":{"rendered":"Unity : utiliser les Prefabs pour garder un projet propre"},"content":{"rendered":"<p>Un Prefab est un mod\u00e8le de GameObject enregistr\u00e9 dans le projet. Il permet de cr\u00e9er plusieurs instances partageant la m\u00eame structure et les m\u00eames r\u00e9glages de base.<\/p>\n<h2>Quand cr\u00e9er un Prefab ?<\/h2>\n<p>Cr\u00e9ez un Prefab d\u00e8s qu\u2019un objet doit appara\u00eetre plusieurs fois : ennemi, projectile, bonus, \u00e9l\u00e9ment de d\u00e9cor ou interface.<\/p>\n<h2>Cr\u00e9er votre premier Prefab<\/h2>\n<ol>\n<li>Pr\u00e9parez un GameObject complet dans la hi\u00e9rarchie.<\/li>\n<li>Faites-le glisser vers un dossier Prefabs du projet.<\/li>\n<li>Supprimez l\u2019objet de test et glissez le Prefab dans la sc\u00e8ne.<\/li>\n<\/ol>\n<h2>Instances et modifications<\/h2>\n<p>Une modification appliqu\u00e9e au Prefab est propag\u00e9e \u00e0 ses instances. Vous pouvez n\u00e9anmoins remplacer localement certaines valeurs, par exemple la couleur ou les points de vie d\u2019un ennemi particulier.<\/p>\n<h2>Exercice pratique<\/h2>\n<p>Cr\u00e9ez un Prefab Projectile avec un sprite, un collider et un script de d\u00e9placement. Instanciez-le depuis le script du joueur lorsque la touche de tir est press\u00e9e.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Transformez vos GameObjects en mod\u00e8les r\u00e9utilisables et \u00e9vitez les modifications r\u00e9p\u00e9titives dans toutes vos sc\u00e8nes.<\/p>\n","protected":false},"author":0,"featured_media":16,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[10,9],"class_list":["post-12","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-unity","tag-c","tag-unity"],"_links":{"self":[{"href":"https:\/\/gamecodeur.animapix.fr\/index.php?rest_route=\/wp\/v2\/posts\/12","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gamecodeur.animapix.fr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gamecodeur.animapix.fr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/gamecodeur.animapix.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12"}],"version-history":[{"count":0,"href":"https:\/\/gamecodeur.animapix.fr\/index.php?rest_route=\/wp\/v2\/posts\/12\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gamecodeur.animapix.fr\/index.php?rest_route=\/wp\/v2\/media\/16"}],"wp:attachment":[{"href":"https:\/\/gamecodeur.animapix.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gamecodeur.animapix.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gamecodeur.animapix.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}