{"id":10356,"date":"2021-08-19T10:00:53","date_gmt":"2021-08-19T01:00:53","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=10356"},"modified":"2021-08-19T11:58:42","modified_gmt":"2021-08-19T02:58:42","slug":"unity-%e3%82%ab%e3%83%a1%e3%83%a9%e3%81%ab%e8%bf%bd%e5%be%93%e3%81%99%e3%82%8bgameobject%e3%81%a8%e8%a4%87%e8%a3%bd2","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/10356","title":{"rendered":"[Unity] \u30ab\u30e1\u30e9\u306b\u8ffd\u5f93\u3059\u308bGameObject\u3068\u8907\u88fd(2)"},"content":{"rendered":"\n<p>\u4eca\u56de\u306f\u30ab\u30e1\u30e9\u306b\u8ffd\u5f93\u3059\u308bGameObject\u3068\u8907\u88fd\u3059\u308b\u65b9\u6cd5\u3092\u30b7\u30a7\u30a2\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<br> \u672c\u8a18\u4e8b\u306f\u524d\u56de\u306e\u300c<a rel=\"noreferrer noopener\" aria-label=\"[Unity] \u30ab\u30e1\u30e9\u306b\u8ffd\u5f93\u3059\u308bGameObject\u3068\u8907\u88fd(1) (\u65b0\u3057\u3044\u30bf\u30d6\u3067\u958b\u304f)\" href=\"\/appnews\/archives\/10325\" target=\"_blank\">[Unity] \u30ab\u30e1\u30e9\u306b\u8ffd\u5f93\u3059\u308bGameObject\u3068\u8907\u88fd(1)<\/a>\u300d\u306e\u7d9a\u304d\u3067\u3059\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<h4>Cube\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u914d\u7f6e<\/h4>\n\n\n\n<p>GameObject\u30e1\u30cb\u30e5\u30fc\u304b\u3089 3D Object &gt; Cube \u3092\u9078\u629e\u3057\u307e\u3059\u3002<br> \u30d2\u30a8\u30e9\u30eb\u30ad\u30fc\u4e0a\u306bCube\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u914d\u7f6e\u3055\u308c\u307e\u3059\u304c\u3001\u3053\u306e\u6bb5\u968e\u3067\u306f\u30ab\u30e1\u30e9\u306b\u8ffd\u5f93\u3057\u307e\u305b\u3093\u3002<br> \u30ab\u30e1\u30e9\u306b\u8ffd\u5f93\u3055\u305b\u308b\u306b\u306f\u3001\u4e0b\u56f3\u306e\u3088\u3046\u306bMain Camera\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u4e0b\u306e\u968e\u5c64\u306bCube\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u30c9\u30e9\u30c3\u30b0\u3057\u3066\u89aa\u5b50\u95a2\u4fc2\u306b\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br> (Cube\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u540d\u79f0\u306f\u300cCameraCube\u300d\u306b\u3057\u307e\u3057\u305f)<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"202\" height=\"142\" src=\"\/appnews\/wp-content\/uploads\/sites\/4\/2021\/08\/3.png\" alt=\"\" class=\"wp-image-10359\"\/><\/figure>\n\n\n\n<p>\u3053\u306e\u6bb5\u968e\u3067Play\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u4e0b\u306e\u3088\u3046\u306b\u3001<br> \u30ab\u30e1\u30e9\u306e\u5411\u304d\u306b\u5fdc\u3058\u3066Cube\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u8ffd\u5f93\u3059\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"640\" height=\"333\" src=\"\/appnews\/wp-content\/uploads\/sites\/4\/2021\/08\/1-1.gif\" alt=\"\" class=\"wp-image-10361\"\/><\/figure>\n\n\n\n<h4>GameObject\u306e\u8907\u88fd\u3068\u914d\u7f6e\u5ea7\u6a19\u3068\u5411\u304d\u306e\u8abf\u6574<\/h4>\n\n\n\n<p>\u6b21\u306b\u30b9\u30da\u30fc\u30b9\u30ad\u30fc\u3092\u62bc\u3057\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u3001\u305d\u306e\u5834\u6240\u306bCube\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u8907\u88fd\u304c\u56fa\u5b9a\u3055\u308c\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>Assets\u5185\u306bScript\u3092\u65b0\u898f\u4f5c\u6210\u3057\u307e\u3059\u3002<br> Script\u540d\u306f\u300cDirectorScript\u300d\u3068\u3057\u307e\u3057\u305f\u3002<br> \u4ee5\u4e0b\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\n\npublic class DirectorScript : MonoBehaviour\n{\n\n    public GameObject originalobj;\n\n    \/\/ Update is called once per frame\n    void Update()\n    {\n        if (Input.GetKeyDown(\"space\"))\n        {\n\n            \/\/ \u8907\u88fd\u5143\u306e3D\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306etransform\u3092\u53d6\u5f97\n            Transform myTransform = originalobj.transform;\n\n            \/\/ \u8907\u88fd\u5143\u306e3D\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5ea7\u6a19\u3092\u53d6\u5f97\n            Vector3 pos = myTransform.position;\n\n            \/\/ \u8907\u88fd\u5143\u306e3D\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u56de\u8ee2(\u30aa\u30a4\u30e9\u30fc\u89d2)\u3092\u53d6\u5f97\n            var angles = originalobj.transform.rotation.eulerAngles;\n\n            \/\/ \u30b3\u30d4\u30fc\u3057\u3066\u914d\u7f6e\u3059\u308b\n            GameObject copied = Object.Instantiate(originalobj, pos, Quaternion.Euler(angles)) as GameObject;\n            copied.name = \"copiedCube\";\n\n        }\n\n    }\n\n}<\/code><\/pre>\n\n\n\n<p>public\u3067\u8a2d\u5b9a\u3057\u3066\u3044\u308bGameObject originalobj \u306f\u8907\u88fd\u5143\u306e\u30aa\u30ea\u30b8\u30ca\u30eb\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u8a2d\u5b9a\u3092\u304a\u3053\u306a\u3044\u307e\u3059\u3002<br> \u4eca\u56de\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306boriginalobj\u306b\u306f\u300cCameraCube\u300d\u3092\u8a2d\u5b9a\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"276\" height=\"71\" src=\"\/appnews\/wp-content\/uploads\/sites\/4\/2021\/08\/4.png\" alt=\"\" class=\"wp-image-10364\"\/><\/figure>\n\n\n\n<p>Play\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u4e0b\u306e\u3088\u3046\u306b\u3001\u30b9\u30da\u30fc\u30b9\u30ad\u30fc\u3092\u62bc\u3057\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u3001\u305d\u306e\u5834\u6240\u306bCube\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u8907\u88fd\u304c\u751f\u6210\u3055\u308c\u3001\u56fa\u5b9a\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" width=\"640\" height=\"333\" src=\"\/appnews\/wp-content\/uploads\/sites\/4\/2021\/08\/2-1.gif\" alt=\"\" class=\"wp-image-10365\"\/><\/figure>\n\n\n\n<p>\u8907\u88fd\u3057\u305fCube\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306bDestroy\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u7834\u68c4\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GameObject copiedCube = GameObject.Find(\"copiedCube\");\nDestroy(copiedCube);<\/code><\/pre>\n\n\n\n<p>\u6728\u66dc\u65e5\u62c5\u5f53\uff1anishida<\/p>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/10356\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/10356\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"[Unity] \u30ab\u30e1\u30e9\u306b\u8ffd\u5f93\u3059\u308bGameObject\u3068\u8907\u88fd(2)\" data-hatena-bookmark-layout=\"standard\" title=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\"> <img src=\"\/\/b.hatena.ne.jp\/images\/entry-button\/button-only@2x.png\" alt=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\" width=\"20\" height=\"20\" style=\"border: none;\" \/><\/a><script type=\"text\/javascript\" src=\"\/\/b.hatena.ne.jp\/js\/bookmark_button.js\" charset=\"utf-8\" async=\"async\"><\/script><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/10356\" data-text=\"[Unity] \u30ab\u30e1\u30e9\u306b\u8ffd\u5f93\u3059\u308bGameObject\u3068\u8907\u88fd(2)\" data-via=\"GIGASJAPAN_APPS\" data-lang=\"ja\">Tweet<\/a><\/div>\n            <div class=\"wsbl_facebook_like\"><div id=\"fb-root\"><\/div><fb:like href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/10356\" layout=\"button_count\" action=\"like\" width=\"100\" share=\"false\" show_faces=\"false\" ><\/fb:like><\/div>\n            <div class=\"wsbl_facebook_send\"><div id=\"fb-root\"><\/div><fb:send href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/10356\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u56de\u306f\u30ab\u30e1\u30e9\u306b\u8ffd\u5f93\u3059\u308bGameObject\u3068\u8907\u88fd\u3059\u308b\u65b9\u6cd5\u3092\u30b7\u30a7\u30a2\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 \u672c\u8a18\u4e8b\u306f\u524d\u56de\u306e\u300c[Unity] \u30ab\u30e1\u30e9\u306b\u8ffd\u5f93\u3059\u308bGameObject\u3068\u8907\u88fd(1)\u300d\u306e\u7d9a\u304d\u3067\u3059\u3002<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[109],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/10356"}],"collection":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/comments?post=10356"}],"version-history":[{"count":7,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/10356\/revisions"}],"predecessor-version":[{"id":10496,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/10356\/revisions\/10496"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=10356"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=10356"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=10356"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}