Unity¤Ë´ØÏ¢¤¹¤ëµ­»ö¤Ç¤¹

¡¡¥¯¥é¥¹¤Îʬ³äÊýË¡¤Ë¤Ä¤¤¤Æ²òÀ⤷¤Þ¤¹¡£

¡¡¥¯¥é¥¹¤Îʬ³ä¤Ï¡¢¥×¥í¥°¥é¥à¤Î²ÄÆÉÀ­¤ÈÊݼéÀ­¤ò¸þ¾å¤µ¤»¡¢¥Ð¥°¤ÎȯÀ¸¤ò¸º¤é¤¹¤¿¤á¤Î½ÅÍפʵ»½Ñ¤Ç¤¹¡£



ʬ³äÁ°¤Î¥µ¥ó¥×¥ë¥³¡¼¥É


¡¡¤Þ¤º¤Ï¡¢Ã±°ì¤Î¥¯¥é¥¹¤¬Ê£¿ô¤Î¥¿¥¹¥¯¤ò°·¤¦°Ê²¼¤Î¥µ¥ó¥×¥ë¥³¡¼¥É¤ò¹Í¤¨¤Æ¤ß¤Þ¤·¤ç¤¦¡£¤³¤³¤Ç¤Ï¡¢¥¹¥³¥¢¤Î´ÉÍý¤Èɽ¼¨¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹


using UnityEngine;
using UnityEngine.UI;

public class ScoreDirector : MonoBehaviour
{
    // ¥¹¥³¥¢¤òÊݸ¤¹¤ëÊÑ¿ô
    private int score = 0;

    // ¥¹¥³¥¢¤Ë²Ã»»¤¹¤ëÃͤòÊÝ»ý¤¹¤ëÊÑ¿ô
    [SerializeField]
    private int point = 0;

    // ¥¹¥³¥¢É½¼¨ÍѤÎText¥³¥ó¥Ý¡¼¥Í¥ó¥È
    [SerializeField]
    private Text scoreText;


    // ¥¹¥³¥¢¤ò²Ã»»¤¹¤ë¥á¥½¥Ã¥É
    public void AddScore(int amount)
    {
        score += amount;
        Debug.Log("Score added. Current score: " + score);
    }

    // ¥¹¥³¥¢¤òɽ¼¨¤¹¤ë¥á¥½¥Ã¥É
    public void DisplayScore(int score)
    {
        scoreText.text = "Score: " + score;  // ¥¹¥³¥¢¤ò¥Æ¥­¥¹¥È¤Çɽ¼¨
¡¡¡¡¡¡¡¡Debug.Log("Your total score is: " + score);       
    }

    void Start()
    {
        // ¥Ç¥Ð¥Ã¥°ÍÑ
        AddScore(point);

        DisplayScore(score);
    }
}

¡¡¤³¤ÎScoreDirector¥¯¥é¥¹¤Ç¤Ï¡¢¥¹¥³¥¢¤Î²Ã»»¤Èɽ¼¨¤ò´ÉÍý¤·¤Æ¤¤¤Þ¤¹¡£
scoreÊÑ¿ô¤Ï¥¹¥³¥¢¤òÊÝ»ý¤·¡¢AddScore¥á¥½¥Ã¥É¤Ï¥¹¥³¥¢¤ò²Ã»»¤·¡¢DisplayScore¥á¥½¥Ã¥É¤Ï¥¹¥³¥¢¤òɽ¼¨¤·¤Þ¤¹¡£

¡¡°ì¸«¡¢¤¹¤Ù¤Æ¤¬À°Íý¤µ¤ì¤Æ¤¤¤Æ¼êº¢¤Ê¤è¤¦¤Ë¸«¤¨¤Þ¤¹¤¬¡¢¥¯¥é¥¹¤¬Â礭¤¯¤Ê¤ê»Ï¤á¤ë¤ÈÌäÂ꤬À¸¤¸¤Þ¤¹¡£


¥¯¥é¥¹¤ÎÈîÂç²½¤Ë¤è¤ë¥Ç¥á¥ê¥Ã¥È


¡¡¥¯¥é¥¹¤¬Â礭¤¯¤Ê¤ë¤È¡¢¤½¤ì¤Ï¥³¡¼¥É¤Î´ÉÍý¤¬Æñ¤·¤¯¤Ê¤ë¤³¤È¤ò°ÕÌ£¤·¤Þ¤¹¡£
ÆÃÄê¤Î¥á¥½¥Ã¥É¤ò¸«¤Ä¤±¤ë¤Î¤¬º¤Æñ¤Ë¤Ê¤ê¡¢¤Þ¤¿¡¢ÆÃÄê¤ÎÊÑ¿ô¤¬¤É¤Î¥á¥½¥Ã¥É¤Ë±Æ¶Á¤òÍ¿¤¨¤ë¤«ÇÄ°®¤¹¤ë¤Î¤âÆñ¤·¤¯¤Ê¤ê¤Þ¤¹¡£
¤½¤Î·ë²Ì¡¢¥Ð¥°¤¬È¯À¸¤·¤ä¤¹¤¯¤Ê¤ê¡¢¥Ç¥Ð¥Ã¥°¤âº¤Æñ¤Ë¤Ê¤ê¤Þ¤¹¡£

¡¡¤µ¤é¤Ë¡¢Â礭¤Ê¥¯¥é¥¹¤ÏºÆÍøÍÑÀ­¤âÄã²¼¤·¤Þ¤¹¡£
°ìÉô¤Îµ¡Ç½¤À¤±¤¬Ê̤ξì½ê¤ÇɬÍפʾì¹ç¤Ç¤â¡¢¤½¤ÎÂ礭¤Ê¥¯¥é¥¹Á´ÂΤòºÆÍøÍѤ¹¤ë¤³¤È¤Ë¤Ê¤ê¡¢É¬Íפʤ¤µ¡Ç½¤Þ¤Ç´Þ¤Þ¤ì¤Æ¤·¤Þ¤¤¤Þ¤¹¡£

¡¡¤·¤¿¤¬¤Ã¤Æ¡¢¥¯¥é¥¹¤òŬÀÚ¤Ëʬ³ä¤¹¤ë¤³¤È¤Ç¡¢¤³¤ì¤é¤ÎÌäÂê¤ò·Ú¸º¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
¼¡¤Î¥Ñ¡¼¥È¤Ç¤Ï¡¢¤³¤Î¥¯¥é¥¹¤ò¤É¤Î¤è¤¦¤Ëʬ³ä¤¹¤ë¤«¤ò²òÀ⤷¤Þ¤¹¡£


Ìò³ä¤Ë±þ¤¸¤¿¥¯¥é¥¹¤Îʬ³ä


¡¡¥¹¥³¥¢¤Î²Ã»»¤Èɽ¼¨¤ò°ì¤Ä¤Î¥¯¥é¥¹¤Ç´ÉÍý¤¹¤ë¥µ¥ó¥×¥ë¥³¡¼¥É¤ò¸«¤Þ¤·¤¿¡£
º£²ó¤Ï¤³¤Î¥¯¥é¥¹¤ò£²¤Ä¤Ëʬ³ä¤·¡¢³Æ¥¯¥é¥¹¤¬°ì¤Ä¤ÎÌò³ä¤À¤±¤ò»ý¤Ä¤è¤¦¤Ë¤·¤Þ¤¹¡£

¡¡ScoreManager¥¯¥é¥¹Æâ¤Ë¤¢¤Ã¤¿½èÍý¤ò¾¤Î¥¯¥é¥¹¤Ë°Ñ¾ù¤·¡¢¥¹¥³¥¢¤Î²Ã»»¤Èɽ¼¨¤òÄ´À°¤·¤Þ¤¹¡£



£±¡¥Score¥¯¥é¥¹


¡¡¤Þ¤º¡¢¥¹¥³¥¢¤Î´ÉÍý¤òôÅö¤¹¤ëScore¥¯¥é¥¹¤òºîÀ®¤·¤Þ¤¹¡£


using UnityEngine;

public class Score : MonoBehaviour
{
    // ¥¹¥³¥¢¤òÊݸ¤¹¤ëÊÑ¿ô
    private int score = 0;

    // ¥¹¥³¥¢¤ò²Ã»»¤¹¤ë¥á¥½¥Ã¥É
    public void AddScore(int amount)
    {
        score += amount;
    }

    // ¸½ºß¤Î¥¹¥³¥¢¤ò¼èÆÀ¤¹¤ë¥á¥½¥Ã¥É
    public int GetScore()
    {
        return score;
    }
}


£²¡¥ScoreDisplay¥¯¥é¥¹


¡¡¼¡¤Ë¡¢¥¹¥³¥¢¤Îɽ¼¨¤òôÅö¤¹¤ëScoreDisplay¥¯¥é¥¹¤òºîÀ®¤·¤Þ¤¹¡£

using UnityEngine;
using UnityEngine.UI;

public class ScoreDisplay : MonoBehaviour
{
    // ¥¹¥³¥¢¤òɽ¼¨¤¹¤ë¤¿¤á¤ÎText¥³¥ó¥Ý¡¼¥Í¥ó¥È
    public Text scoreText;

    // ¥¹¥³¥¢¤òɽ¼¨¤¹¤ë¥á¥½¥Ã¥É
    public void DisplayScore(int score)
    {
        scoreText.text = "Score: " + score;  // ¥¹¥³¥¢¤ò¥Æ¥­¥¹¥È¤Çɽ¼¨
    }
}

£³¡¥ScoreManager¥¯¥é¥¹


¡¡¤½¤·¤Æ¡¢ºÇ¸å¤Ë¡¢¥¹¥³¥¢¤Î²Ã»»¤Èɽ¼¨¤òÄ´À°¤¹¤ë¿·¤¿¤ÊScoreManager¥¯¥é¥¹¤òºîÀ®¤·¤Þ¤¹¡£

using UnityEngine;

public class ScoreManager : MonoBehaviour
{
    // Score¥¯¥é¥¹¤ÈScoreDisplay¥¯¥é¥¹¤Ø¤Î»²¾È
    public Score score;
    public ScoreDisplay scoreDisplay;

    // ¥¹¥³¥¢¤ò²Ã»»¤·¡¢É½¼¨¤ò¹¹¿·¤¹¤ë¥á¥½¥Ã¥É
    public void AddScore(int amount)
    {
        score.AddScore(amount);
        scoreDisplay.DisplayScore(score.GetScore());
    }
}

¡¡¤³¤Î¤è¤¦¤Ë¡¢ScoreManager¥¯¥é¥¹¤¬Score¥¯¥é¥¹¤ÈScoreDisplay¥¯¥é¥¹¤ò´ÉÍý¤·¡¢¤½¤ì¤é¤òÏ¢·È¤µ¤»¤Þ¤¹¡£
¤³¤ì¤Ë¤è¤ê¡¢³Æ¥¯¥é¥¹¤Ï°ì¤Ä¤ÎÌò³ä¤ËÀìÇ°¤·¡¢Â¾¤Î¥¯¥é¥¹¤ÈÁ·ë¹ç¤Ë¤Ê¤ë¤³¤È¤¬²Äǽ¤Ë¤Ê¤ê¤Þ¤¹¡£

¡¡¤³¤Î¤è¤¦¤ÊÀ߷פϡ¢¥³¡¼¥É¤Î²ÄÆÉÀ­¡¢ÊݼéÀ­¡¢ºÆÍøÍÑÀ­¤ò¸þ¾å¤µ¤»¤ë¤Î¤ËÌòΩ¤Á¤Þ¤¹¡£


¥¯¥é¥¹¤Îʬ³ä¤Ë¤è¤ë¥á¥ê¥Ã¥È


¡¡Ê¬³ä¸å¤Î¥¯¥é¥¹¤Ï¤½¤ì¤¾¤ì¤ÎÌò³ä¤ËÆò½¤·¤Æ¤¤¤ë¤¿¤á¡¢¥³¡¼¥É¤Î²ÄÆÉÀ­¤ÈÊݼéÀ­¤¬¸þ¾å¤·¤Þ¤¹¡£
¤½¤ì¤¾¤ì¤Î¥¯¥é¥¹¤¬¾®¤µ¤¯¤Ê¤Ã¤¿¤¿¤á¡¢ÆÃÄê¤Î¥á¥½¥Ã¥É¤äÊÑ¿ô¤ò¸«¤Ä¤±¤ä¤¹¤¯¤Ê¤ê¡¢¥Ç¥Ð¥Ã¥°¤âÍưפˤʤê¤Þ¤¹¡£

¡¡¤Þ¤¿¡¢³Æ¥¯¥é¥¹¤¬ÆÈΩ¤·¤Æ¤¤¤ë¤¿¤á¡¢É¬Íפʵ¡Ç½¤À¤±¤òºÆÍøÍѤ¹¤ë¤³¤È¤¬Íưפˤʤê¤Þ¤¹¡£
Î㤨¤Ð¡¢¥¹¥³¥¢¤Î²Ã»»¤À¤±¤¬É¬Íפʾì¹ç¤ÏScore¥¯¥é¥¹¤À¤±¤ò»ÈÍѤ·¡¢¥¹¥³¥¢¤Îɽ¼¨¤¬É¬Íפʾì¹ç¤ÏScoreDisplay¥¯¥é¥¹¤òÄɲ乤ë¤À¤±¤Ç¤¹¡£

¡¡¤³¤Î¤è¤¦¤Ë¡¢¥¯¥é¥¹¤Îʬ³ä¤Ï¡¢¤è¤êÎɤ¤¥³¡¼¥É¤ÎÀ߷פȳ«È¯¤ò¼Â¸½¤¹¤ë¤¿¤á¤Î½ÅÍפʼêË¡¤Ç¤¹¡£


Ê£¿ô¤Î¥¯¥é¥¹¤Îʬ³ä»þ¤Î¹Í¤¨Êý


¡¡¥×¥í¥°¥é¥à¤Ë¤ª¤¤¤Æ¤Ï¡¢Ê£¿ô¤Î¥¯¥é¥¹¤òÍøÍѤ¹¤ë¥±¡¼¥¹¤ÎÊý¤¬Â¿¤¯¤¢¤ê¤Þ¤¹¡£
¤Þ¤¿¥·¡¼¥óÁ«°Ü¤Î¤³¤È¤Ê¤É¤â¹Í¤¨¤¿À߷פò¹Ô¤¦¥±¡¼¥¹¤â¤¢¤ë¤¿¤á¡¢Ê£¿ô¤Î¥¯¥é¥¹¤¬¤É¤Î¤è¤¦¤Ë¤·¤Æ¤Ä¤Ê¤¬¤Ã¤Æ¤¤¤ë¤Î¤«¡¢ÇÄ°®¤¬Æñ¤·¤¤¤³¤È¤â¿¤¤¤Ç¤¹¡£

¡¡¤½¤¦¤¤¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢°ìÅÙ¡¢¤³¤¦¤¤¤Ã¤¿¥Ù¡¼¥·¥Ã¥¯¤Ê·Á¤Ç¡¢£±¤Ä¤Î¥¯¥é¥¹Æâ¤Ë¡¢¤ä¤ê¤¿¤¤½èÍý¤ò¤Þ¤È¤á¤Æ½ñ¤¤¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
¤½¤ì¤«¤é¡¢Ìò³ä¤ò¹Í¤¨¤¿¾å¤Ç¡¢¥¯¥é¥¹¤òʬ³ä¤·¤Æ¤¤¤¯¤³¤È¤Ç¡¢É¬ÍפʾðÊó¤äʬ³ä¤·¤¿Êý¤¬¤è¤¤¾ðÊ󤬸«¤¨¤Æ¤­¤Þ¤¹¡£

¡¡½èÍý¤¬Ê£»¨¤Ë¤Ê¤ì¤Ð¤Ê¤ë¤Û¤É¡¢º®Íð¤òÀ¸¤¸¤ä¤¹¤¯¤Ê¤ê¤Þ¤¹¡£

¡¡¾ï¤Ë´ðËܤò¥¤¥á¡¼¥¸¤·¡¢´ðËܤËΩ¤ÁÌá¤Ã¤Æ¹Í¤¨¤ë¤è¤¦¤Ë¤·¤Æ¤ß¤ë¤³¤È¤Ç¡¢Ê¬³ä¤ÎÊýË¡¤ØÍý²ò¤¬¿¼¤Þ¤ê¤Þ¤¹¡£

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


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

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

Menu


´ðÁÃ

µ»½Ñ/Ãμ±(¼ÂÁõÎã)

3D¥¢¥¯¥·¥ç¥ó¥²¡¼¥à

2D¤ª¤Ï¤¸¤­¥²¡¼¥à(ȯŸÊÔ)

2D¶¯À©²£¥¹¥¯¥í¡¼¥ë¥¢¥¯¥·¥ç¥ó(ȯŸÊÔ)

2D¥¿¥Ã¥×¥·¥å¡¼¥Æ¥£¥ó¥°(³ÈÄ¥ÊÔ)

¥ì¡¼¥¹¥²¡¼¥à(È´¿è)

2DÊüÃÖ¥²¡¼¥à(ȯŸÊÔ)

3D¥ì¡¼¥ë¥¬¥ó¥·¥å¡¼¥Æ¥£¥ó¥°(±þÍÑÊÔ)

3Dæ½Ð¥²¡¼¥à(È´¿è)

2D¥ê¥¢¥ë¥¿¥¤¥à¥¹¥È¥é¥Æ¥¸¡¼

3D¥¿¥Ã¥×¥¢¥¯¥·¥ç¥ó(NavMeshAgent »ÈÍÑ)

2D¥È¥Ã¥×¥Ó¥å¡¼¥¢¥¯¥·¥ç¥ó(¥«¥¨¥ë¤Î°Ù¤Ë¡Á¡¢¥Ü¥³¥¹¥«¥¦¥©¡¼¥ºÉ÷)

VideoPlayer ¥¤¥Ù¥ó¥ÈϢư¤Î¼ÂÁõÎã

VideoPlayer ¥ê¥¹¥ÈÆ⤫¤é¥à¡¼¥Ó¡¼ºÆÀ¸¤Î¼ÂÁõÎã(ȯŸ)

AR ²èÁüÉÕ¤­¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¤Î¼ÂÁõÎã

AR ¥ê¥¹¥ÈÆ⤫¤éÀ¸À®¤Î¼ÂÁõÎã(ȯŸ)

2D¥È¥Ã¥×¥Ó¥å¡¼¥¢¥¯¥·¥ç¥ó(¥µ¥Ð¥¤¥Ð¡¼É÷)

private



¤³¤Î¥µ¥¤¥ÈÆâ¤ÎºîÉʤϥæ¥Ë¥Æ¥£¤Á¤ã¤ó¥é¥¤¥»¥ó¥¹¾ò¹à¤Î¸µ¤ËÄ󶡤µ¤ì¤Æ¤¤¤Þ¤¹¡£

´ÉÍý¿Í/Éû´ÉÍý¿Í¤Î¤ßÊÔ½¸¤Ç¤­¤Þ¤¹