第4åå¦çã®ããã®Unityåå¼·ä¼ã«åå ãã¾ãã
æè¿ããããã®ã«åå åºæ¥ã¦ãªãã£ããããããããã¾ãè¡ãå§ãããã¨æã£ã¦ãã¡ããã©è¦ã¤ãã第4回学生のためのUnity勉強会 in リクルート メディアテクノロジーラボ : ATNDã«åå ãã¾ãããUnityã¯JavaScript(UnityScript)*1ã§æ¸ãã¦ããã©ãæ¬æ¥ã®JavaScriptã«æ £ãã¦ããã°ããã»ã©ãUnityã®JavaScriptã§åºæ¥ãªããã¨ãæ°ã«ãªã£ã¦ãã¾ãã®ã§ãC#ã§ãã£ã¦ã¿ããã¨æã£ã¦ãã¨ããã ã£ãããã¾ãã
ææ³
ã¡ããã©Unityã¯C#ã§ããããã¨æã£ã¦ããã¨ãããå¦çã®ããã®ã¨ããååã®éããUnityã®äºã ããããªãã¦C#ã®åºæ¬çãªäºã話ãã¦è²°ãã¾ãããã¨ããããC#ã®åºæ¬çãªã¨ãããè©°ãè¾¼ã¿ã§è©±ãã¤ã¤ãUnityã§ã®ä½¿ããããã¿ãããªã®ã«è§¦ããå½¢ã§ããã£ãã§ããã¹ã©ã¤ãã®ã¿ã¤ãã«ããUnityã§è¦ããC#ãã ãã
ã¹ã©ã¤ã57ãã¼ã¸ã1æéã¡ããã§ã¨ããäºããã£ã¦ãããªãé§ã足ã§é²ãã§ãã®ã§ãæåã¯ç解ã説æã«ã¤ãã¦ããããªã¨æã£ããã©ã説æãã¹ã©ã¤ãã¸ã®ã¾ã¨ãæ¹ããã¾ãã®ããèãã¦ãã ãã§æ®éã«ã¤ãã¦ãã¦ã¾ãããC#ãªãã§ã¯ã®æ©è½ãçµæ§ç´¹ä»ããã¦ã¦ã1æéã¡ãã£ã¨ã®èããã ãã ãã©ãC#ã®äºãåãã£ãæ°åã«ãªãã¾ããã
å¦çã®ããã®åå¼·ä¼ã ãã©ãå¦çãããªãã¦ãåå ãã¦ãè¯ãã¨ããäºã§åå ãã¾ããããå¨ããã¿ãã¨ãã¾ãå¦çã£ã½ã人ã¯å¤ããªãã£ãã§ããä¼ã®æå¾ã«ææã§ãã£ããã¨æ°ãã¦ããã©ãååå¼±ã£ã¦æãã§ããã
URL
ã¹ã©ã¤ã
ã¡ã¢
ã¹ã©ã¤ããå
¬éããã¦ãã®ã§ã以ä¸ã¯èªåãã¡ã¢ããäºãçå½ã«ãã¹ã©ã¤ãã¨ãã¶ã£ã¦ãããã ãã©æ¸ãã¦ããã¾ãã
ããã«æ¸ãã«ããã£ã¦ãåå¼·ä¼ã§åã£ãã¡ã¢ã¨è¨æ¶ãé ¼ãã«ãèªåã®è¨èã§æ¸ãã¦ãã®ã§ãåéãã¨ãééãã¨ããã¥ã¢ã³ã¹éãã¨ããããã¨æãã¾ãã
ãªãã¡ã¬ã³ã¹ã¯MSDNãè¦ã
C# 6.0 のドラフト言語仕様 | Microsoft Docs
ãã®è¾ºããªï¼
ã³ã³ãã¼ãã³ãå¿å
Unityã§ã¯ç¶æ¿ããã³ã³ãã¼ãã³ãã¨ãã¦ã³ã¼ãæ¸ããæ¹ãè¯ãå ´åãå¤ãã端çã«è¨ãã°MonoBehaviorãç¶æ¿ããã¨Update()ãAwake()ãªã©ã使ããããããã®è¾ºä½¿ã£ã¦ä½ãã°ã³ã³ãã¼ãã³ãã«ãªããGameObjectãç¶æ¿ããããããããã£ã¦ä½ã£ãã³ã³ãã¼ãã³ããGameObjectã«ä»ãããå¤ãããããããæ¹ã
ä¾ãã°ããã£ã©ã¯ã¿ã¼ã®GameObjectã«ããã¬ã¼ã¤ã¼ãã£ã©ã¯ã¿ã¼ã«ãªãã³ã³ãã¼ãã³ãä»ããããæµã¨ãã¦æ¯èãã³ã³ãã¼ãã³ãä»ãããããµãã¼ããã£ã©ã«ãªãã³ã³ãã¼ãã³ãã¨ä»ãæ¿ãããããã¿ãããªäºãã ã¨æããç¶æ¿ã§ä½ã£ã¦ãã¾ãã¨ãæµãã仲éã«ä»£ããã¿ãããªGameObjectãä½ããªã*2ãã¨ã«ãªã£ã¦ãã¾ãã
ã³ã³ã¹ãã©ã¯ã¿
MonoBehaviorãç¶æ¿ããã¯ã©ã¹ã¯ãã³ã³ã¹ãã©ã¯ã¿ãå®è£ ããäºã¯Unityå´ããéæ¨å¥¨ãAwake()ãStart()ã使ãã¹ãã§ããããããªãã¨Unityããã®ãªãã¸ã§ã¯ãã管çã§ããªãã
ãã¹ãã©ã¯ã¿
C#ã¯GCãããã®ã§ãåºæ¬çã«ä½¿ããªãã
iOSã§ã¯System.GC.Collect();ãå®æçã«å¼ãã ã»ããããããã | PCåãã«ä½æãã¦ãããã®ãiOSã¸ç§»æ¤ããæã®Tips - å¼·ç«ã§é²ã http://goo.gl/CgLyi #uniben4
Twitter. It's what's happening.
ããã·ã¥ã¿ã°ã§ã¡ãã£ã¨è¦ãããã
ããããã£
ããããã¯ã©ã¹ã®ããããã£ã§ã¯ãªããC#ã®æ©è½ã®äºãããã
public Vector3 velocity{ get { return rigidbody.velocity; } set { rigidbody.velocity = value; } }
getter/setterãç°¡æ½ã«æ¸ãããsetterãæ¸ããã«Read Onlyã«ããããã¢ã¯ã»ã¹ä¿®é£¾åãæ¸ãããC#ã®ä¾¿å©ãªæ©è½ã ãã©ãæ®å¿µãªãããã®æ¸ãæ¹ã ã¨Unityã®ã¤ã³ã¹ãã¯ã¿ããã¯è¦ããªãã
ã¤ã³ãã¯ãµã¼
ã¹ã©ã¤ã18ãã¼ã¸ç®ã ãã©ãã©ãããã¹ã©ã¤ãã«ééãããããããããã ãUnityã§ã¯ãã¾ã使ããªãã¨ãã話ã ã£ãã®ã§ãããã£ã¨æµãã¾ããã
ã¢ããªãã¥ã¼ã
ã¯ã©ã¹ãã¡ã½ããã«ã¡ã¿ãã¼ã¿ãä»ããããC#ã®æ©è½ãä¾ãã°Serializableå±æ§ãã¤ããã¨ã¤ã³ã¹ãã¯ã¿ããè¦ããããã«ãªããããã
namespace
å¤åæ®éã«namespaceãUnityçã«ã¯ãMonoBehaviorãç¶æ¿ããã¯ã©ã¹ã¯namespaceã®ä¸ã«å ¥ããã¨ããªããè¦ã¤ãããªããªã£ã¦ãã¾ããããã®ã§ãnamespaceå¤ã«ããªãã¨ã®ãã¨ã
ã¸ã§ããªãã¯
ããªã便å©ã§ä¸æ¼ããªC#ã®æ©è½ãã ãUnityãæä¾ããã¡ã½ããã¯ãã¾ãã¸ã§ããªãã¯ã使ã£ããã®ãå¤ããªããããã
ã©ã ãå¼
ç¡åé¢æ°çãªãã¤ãã³ããªã¹ãã¼*3ã«ç»é²ããã¡ã½ããã§ããã®ã¤ãã³ãã§ã®ã¿ä½¿ç¨ãããã®ãä½ãã¨ãã«ä¾¿å©ãã¤ã³ã¹ã¿ã³ã¹ã¡ã½ããã¨ãã¦ä½ã£ã¡ããã¨ãæ¬æ¥ã¤ãã³ãããããå¼ã°ããªãæ³å®ã®ã¡ã½ãããªã®ã«ãå¥ã®éçºè ãåæã«ä½¿ã£ãããããããããªãããæ©æ¢°çæAPIã«ãè¼ã£ã¦ç ©ãããã
MonoDevelopã¯ä¾¿å©
MonoDevelopã®ãªãã¡ã¯ã¿ãªã³ã°æ©è½ã使ãã°ãã¯ã©ã¹åãã¡ã³ãã¼*4åãå¤ããã¨ãå¼ãã§ãæãåç
§ãã¦ãæãåããã¦å¤ãã¦ããããUnityå´ã§ãã¡ããã¨å¤ãã£ã¦ãã
ã¨ããã¡ã½ããã®å®£è¨ã¸ã®ã¸ã£ã³ãããä½å¦ããå¼ãã§ããããã³ã³ããã¹ãã¡ãã¥ã¼ããåºãããæ®éã«IDEã
ãã ããsendMessage()ã¯å¼æ°ãæååãªãã©ã«ã ããããªãã¡ã¯ã¿ãªã³ã°æ©è½ãéç¨ããªãã
MonoDevelopã«vimã¢ã¼ãããã
ã©ã®ç¨åº¦ã®ãµãã¼ãããã©ãããè¨å®ãããã¯å¿ãããã©ãããããã£ãã¯ãã¨ã®äºã
ãã¬ã¼ã¯ãã¤ã³ãã®ãã¬ã¼ã¹
Run > Attach to processã§Unityã®ããã»ã¹ã«ã¢ã¿ããããã°ããã¬ã¼ã¯ãã¤ã³ãç½®ãã¦ãã¬ã¼ã¹ã§ããããã ãããã¬ã¼ã¯ããã¾ã¾æ¾ç½®ãããããã¨ãMonoDevelopãä¸å®å®ã«ãªããããã¨ãã
MonoDevelopã®.NETã®ãã¼ã¸ã§ã³
MonoDevelopã§ã³ã³ãã¤ã«ãå®è¡ããäºã§ãC#ã®ã³ã¼ãã¨ãã¦ã¡ããã¨æ¸ãã¦ãã確èªã§ãããããã¯Unityã¨ã¯ç¡é¢ä¿ã®ãã®ãªã®ã§ãUnityã®ä¸ã§çºçããã¨ã©ã¼ã¯å½ç¶åãããªããUnityã¯.NET 4.0ã ããMonoDevelopã®å¯¾è±¡ãã¼ã¸ã§ã³ã.NET 3.5ã«ãªã£ã¦ããäºãããã®ã§ã4.0ã«è¨å®ãã¦ããã¨ã¨ã©ã¼æ¤åºãããæ£ç¢ºã«ãªãã
ã»ãã«ãã¡ã¢ã¯æ¸ãããã©
å²ã¨ã¹ã©ã¤ãã«ããUnityã§ã¯ã£ã¦è©±ãæ¸ãã¦ããã®ã§ãå£åã³ãã¼ã¿ãããªå 容ã«ãªããããªã®ã§ãã®ãããã«ãã¦ããã¾ãã
ãã®ä»
åå
ååã¯ã1æéã§FPSãä½ããã¨ããå 容ã ã£ãããããé¢ç½ããã ããæ¢ãã°è³æã¯ããã¯ãã ã¨æããã©ãã¨ããããã¾ã¨ã¾ã£ã¦ãã¨ã³ããªã¼ããã£ãã®ã§URLã ãç½®ãã¦ããã¾ãã
ä¼å ´
ä¼å ´æä¾ã¯ãªã¯ã«ã¼ãã¡ãã£ã¢ãã¯ããã¸ã¼ã©ããªãã ãã©ããªããå¦çéå®ã¤ãã³ããããã®ã§å¦çã®æ¹è¯ãã£ããåå ãã¦ãã ããçãªè©±ãæå¾ã«ããã¾ãããããããåç¥ããçºã®ä¼å ´æä¾ã£ã¦æå³åããããã¨æããã ãã©ãå¦çãããªãã¦ããã¾ããã
ã¤ãã§
http://dl.dropbox.com/u/5606304/JSvsCSharp.pdf
JavaScriptã¨C#ã§åãã³ã¼ããæ¸ãã¦ãæ®ã©å¤ãããªãããã£ã¦PDFã
*1:ãªãã¸ã§ã¯ããªãã©ã«ãæ¸ããªããªã©ãJavaScriptã£ã¦ããUnity JavaScriptã¦å¼ãã æ¹ãããããããªããã¨æã£ã¦ãããã»ãã¨ã«ä»¥åã¯UnityScriptã£ã¦å¼ã°ãã¦ããããã§ãã
*2:GameObjectãä¸æ¦æ¶ãã¦ãã³ã¼ãã¨ãã¦ã¯å¥ç©ã®GameObjectãä½ãã°åºæ¥ããã©
*3:C#ã ã¨ã¤ãã³ããªã¹ãã¼ã£ã¦è¨èãªã®ãã¯ä¸æãããªã²ã¼ã+ã¤ãã³ãã¨ããæ©è½ãããã®ã§ãã¤ãã³ããã³ãã©ã¨ãã¤ãã³ããªã¹ãã¼ã¨ãã¨ã¯ãéã£ãä»çµã¿ãã
*4:ã¡ã½ãããã¡ã³ãã¼å¤æ°