ãUnityéçºãç¶æ¿ã¾ã¨ãâ¡ virtualã¨overrideãã²ããã¨ãã»ã³ã¹ã
Unity5.0.0f4 Personal(2015å¹´5æ)
Â
Â
ã²ããã¨ãã»ã³ã¹ã®æéã§ãã
ååã«å¼ãç¶ããç¶æ¿ã«ã¤ãã¦æ¸ãã¦ããããã¨æãã¾ãã
ä»åã¯virtual修飾åã¨override修飾åã«ã¤ãã¦ã§ãã
Â
 ç¶æ¿ã¾ã¨ãâ¡ virtualã¨override
â ç¶æ¿å¤±æã®ä¾
Animalã¯ã©ã¹ãç¶æ¿ããHiyokoã¯ã©ã¹ãè¼ããã¹ã¯ãªãããä½ãã¾ããã®ã§ã以ä¸ã®ã¹ã¯ãªãããCubeã«è²¼ãä»ãã¦ä¸ããã
Â
Â
Animalã¯ã©ã¹ãã¤ã³ã¹ã¿ã³ã¹åãAnimalFunctionã¡ã½ãããå®è¡ããä¾ã¨ãHiyokoã¯ã©ã¹ãã¤ã³ã¹ã¿ã³ã¹åãAnimalFunctionã¡ã½ãããå®è¡ããä¾ã¨ãæå¾ãå°ãåããã«ããã®ã§ãããHiyokoã¯ã©ã¹ãAnimalã¯ã©ã¹åã§ã¤ã³ã¹ã¿ã³ã¹åï¼ç¶æ¿ãã¦ãã®ã§å¯è½ï¼ããAnimalFunctionã¡ã½ãããå®è¡ããä¾ãè¼ã£ã¦ãã¾ãã
Â
æå¾ã®ä¾ã¯Hiyokoã¯ã©ã¹ãã¤ã³ã¹ã¿ã³ã¹åãã¦ããã®ã§ãã²ããã¯ã©ã¹ã§ããã¨ããæåã表示ãã¦ã»ããã®ã§ãããå®éã¯Animalã¯ã©ã¹ã®ã¡ã½ãããå®è¡ããã¦ãã¾ãã¾ãã
Â
æã£ã¦ãã®ã¨éãã»ã»ã»
Â
ãããæå¾ éãã®å½¢ã«ããããã«ãvirtualã¨overrideã使ãã¾ãã
Â
â¡virtualã¨override
ãã®å ´åæå¾ éãã®å½¢ã«ããããã«ã¯ãã¹ã¼ãã¼ã¯ã©ã¹ã®ã¡ã½ããã«virtual修飾åãããµãã¯ã©ã¹ã®ã¡ã½ããã«override修飾åãä»ããå¿ è¦ãããã¾ããå ã»ã©ã®ã¹ã¯ãªãããä¿®æ£ãã¾ãããã
Â
Â
ãããããã¨ã§ããµãã¯ã©ã¹ç¬èªã®å¤æ°ãã¡ã½ãããå©ç¨ãããã¨ãã§ããããã«ãªãã¾ãã
Â
ãµãã¯ã©ã¹ã®ã¡ã½ãããã¡ããã¨å¼ã°ãã
Â
åãAnimalã¯ã©ã¹åã使ã£ã¦ãããã©çµæãéãã¾ããããããã®ããå¤æ æ§(ããªã¢ã¼ãã£ãºã )ã¨ããããã§ãã
Â
以ä¸ãã²ããã¨ãã»ã³ã¹ã§ããã
ãããã¨ããããã¾ããã
Â