Unity5³Ø½¬¤ÎºÝ¤Î³Ð¤¨½ñ¤­¡£

·ëÏÀ¤Þ¤È¤á

  • return¤¬¼Â¹Ô¤µ¤ì¤ë¤È¡¢´Ø¿ôÆâ¤Î¤½¤ì°Ê¹ß¤Î½èÍý¤Ï¼Â¹Ô¤µ¤ì¤Ê¤¤¡£
  • continue¤Ï¡¢²¼¤òÈô¤Ð¤·¤Æ°ìÈֶᤤfor¤ËÌá¤Ã¤Æ½èÍý¤ò·«¤êÊÖ¤¹
  • break¤Ï¡¢°ìÈֶᤤ¥ë¡¼¥×½èÍý¤òÈ´¤±¤ë


return(for1¤Ä¤Î¥Æ¥¹¥È)

¥Æ¥¹¥È¥³¡¼¥É return­¡

    private string test1 = "£±";
    private string test2 = "£²";
    private string test3 = "£³";

    void Start () {

        for (int i = 0; i < 5; i++)
        {
            Debug.Log(test1);

            if (i == 2)
            {
                Debug.Log(test2);
                return;
            }

            Debug.Log(test3);
        }

	}

¥Æ¥¹¥È¥³¡¼¥É return­¡ ·ë²Ì

£±£³£±£³£±£²

·ëÏÀ

return¤¬¤¢¤ë¤È°Ê¹ß¤Îfor¤Ï²ó¤é¤Ê¤¤¡£


return(for2¤Ä¤Î¥Æ¥¹¥È)

¥Æ¥¹¥È¥³¡¼¥É return­¢

    private string test1 = "£±";
    private string test2 = "£²";
    private string test3 = "£³";

    void Start()
    {

        for (int i = 0; i < 3; i++) {

            for (int j = 0; j < 3; j++)
            {
                Debug.Log(test1);

                if (j == 1)
                {
                    Debug.Log(test2);
                    return;
                }

                Debug.Log(test3);
            }
        }
    }

¥Æ¥¹¥È¥³¡¼¥É return­¢ ·ë²Ì

£±£³£±£²

·ëÏÀ

return¤Ï³°Â¦¤Îfor¤â²ó¤é¤Ê¤¤

return(while - for - for)

¥Æ¥¹¥È¥³¡¼¥É return­£


    private string test1 = "£±";
    private string test2 = "£²";
    private string test3 = "£³";
    private string testz = "£Ú";

    void Start()
    {

        while (true)
        {

            for (int i = 0; i < 3; i++)
            {

                for (int j = 0; j < 3; j++)
                {
                    Debug.Log(test1);

                    if (j == 1)
                    {
                        Debug.Log(test2);
                        return;
                    }

                    Debug.Log(test3);
                }
            }
        }

        Debug.Log(testz);
    }

·ë²Ì

£±£³£±£²

·ëÏÀ

return°Ê¹ßÁ´¤ÆÈô¤Ð¤¹¡£¤â¤·¤«¤·¤Æ¥á¥½¥Ã¥É¤ò½ªÎ»¤µ¤»¤ë¤Ã¤Æ¤³¤È¡©


continue¥Æ¥¹¥È

¥Æ¥¹¥È¥³¡¼¥É continue

    private string test1 = "£±";
    private string test2 = "£²";
    private string test3 = "£³";

    void Start()
    {

        for (int i = 0; i < 3; i++) {

            for (int j = 0; j < 3; j++)
            {
                Debug.Log(test1);

                if (j == 1)
                {
                    Debug.Log(test2);
                    continue;
                }

                Debug.Log(test3);
            }
        }
    }

¥Æ¥¹¥È¥³¡¼¥É continue­¢ ·ë²Ì

£±£³£±£²£±£³£±£³£±£²£±£³£±£³£±£²£±£³

·ëÏÀ

continue¤Ï¡¢²¼¤òÈô¤Ð¤·¤Æ°ìÈֶᤤfor¤ËÌá¤Ã¤Æ½èÍý¤ò·«¤êÊÖ¤¹

¥³¥á¥ó¥È¤ò¤«¤¯


¡Öhttp://¡×¤ò´Þ¤àÅê¹Æ¤Ï¶Ø»ß¤µ¤ì¤Æ¤¤¤Þ¤¹¡£

ÍøÍѵ¬Ìó¤ò¤´³Îǧ¤Î¤¦¤¨¤´µ­Æþ²¼¤µ¤¤

Menu

¡Ú¥á¥Ë¥å¡¼ÊÔ½¸¡Û
Wikiµ­Ë¡¥¬¥¤¥É

¥ê¥ó¥¯

¥²¡¼¥à¥Ð¡¼Âçºå¿´ºØ¶¶

¥²¡¼¥à¥Ð¡¼ÂçºåÇßÅÄ

¥²¡¼¥à¥Ð¡¼Âçºå¿´ºØ¶¶

¥À¡¼¥Ä¡õ¥À¥¤¥Ë¥ó¥°¥Ð¡¼ÂçºåÇßÅÄ

¥á¥Ë¥å¡¼

Unity


¥¹¥Þ¥ÛÁàºî

Unity - GameObject

Unity - 3DCG

¥á¥ó¥Ð¡¼¤Î¤ßÊÔ½¸¤Ç¤­¤Þ¤¹