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

¤³¤Á¤é¤Ï¥ª¥Ö¥¸¥§¥¯¥È¤ËÂФ¹¤ëÁàºî¡Ê²óž¾ðÊó¡Ë¤ò·èÄꤹ¤ë¥¯¥é¥¹¤Ç¤¹¡£
CubeController¤È¤¤¤¦Ì¾¾Î¤Ë¤Ï¤Ê¤Ã¤Æ¤¤¤Þ¤¹¤¬¡¢Â¾¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ë¥¢¥¿¥Ã¥Á¤¹¤ì¤Ð¤½¤Á¤é¤Ç¤âÍøÍѤǤ­¤Þ¤¹¡£

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// ¥ª¥Ö¥¸¥§¥¯¥È¤ÎÁàºî¤ò¹Ô¤¦¥¯¥é¥¹
/// ¸½ºß¤ÏCube¤Ë¥¢¥¿¥Ã¥Á¤¹¤ë¤è¤¦¤Ë¤·¤Æ¤¤¤ë
/// </summary>
public class CubeController : MonoBehaviour
{
    private Test test;       // ¥¯¥é¥¹¼èÆÀÍÑ
    [Header("²óž³ÑÅÙ¤ÎÀßÄêÃÍ")]
    public float eulerAngle;
    private int axis;        // ²óž¤µ¤»¤ë¼´¤ÎÀßÄêÃÍ

    void Start()
    {
        // Test¥¯¥é¥¹¤ò¼èÆÀ¤·testÊÑ¿ô¤ËÂåÆþ = ¥¢¥¯¥»¥¹¤Ç¤­¤ë¾õÂ֤ˤ¹¤ë
        // ¼èÆÀ¤¹¤ëTest¥¯¥é¥¹¤¬Æ±¤¸¥ª¥Ö¥¸¥§¥¯¥È¤Ë¥¢¥¿¥Ã¥Á¤µ¤ì¤Æ¤¤¤ë¾ì¹ç
        // ¾Êά¤·¤Ê¤¤½ñ¤­Êý
        test = this.gameObject.GetComponent<RotateTest>();
        // ¾Êά¤·¤¿½ñ¤­Êý¡Ê´ðËÜ·Á¡Ë
        //test = GetComponent<RotateTest>();
    }

    void Update()
    {
        // ¥Ü¥¿¥ó¤ò²¡¤¹Å٤˲óž¼´¤ò x => y => z => x ¤ÈÊѹ¹¤¹¤ë
        if (Input.GetKeyDown(KeyCode.Z)) {
            axis++;
            // z¤Ë¤Ê¤Ã¤¿¤éx¤ËÌ᤹
            if(axis >= 3) {
                axis = 0;
            }
            Debug.Log(axis);
        }

        if (Input.GetKeyDown(KeyCode.X)) {
            // cube¤ò²óž¤µ¤»¤ë¤¿¤á¡¢Test¥¯¥é¥¹¤ÎRotateCube¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹
            // Â裱°ú¿ô¤È¤·¤Æ²óž¤¹¤ë³ÑÅÙ¡¢Â裲°ú¿ô¤È¤·¤Æ²óž¤ò¤µ¤»¤ë¼´¤Î¾ðÊó¤òÅϤ¹
            // ¥¢¥¯¥»¥¹¤¹¤ë¾ì¹ç¤Ë¤Ï¡¢[¥¯¥é¥¹¤ÎÂåÆþ¤µ¤ì¤Æ¤¤¤ëÊÑ¿ô̾].[¸Æ¤Ó½Ð¤¹¥á¥½¥Ã¥É̾]¤Ç½ñ¤¯ 
            test.RotateCube(eulerAngle, axis);
        }
        if (Input.GetKeyDown(KeyCode.C)) {
            // cube¤ò²óž¤µ¤»¤ë¤¿¤á¡¢Test¥¯¥é¥¹¤ÎRotateCube¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹
            // Â裱°ú¿ô¤È¤·¤Æ²óž¤¹¤ë³ÑÅÙ¡¢Â裲°ú¿ô¤È¤·¤Æ²óž¤ò¤µ¤»¤ë¼´¡¢Â裳°ú¿ô¤È¤·¤ÆµÕ²óž¤Î¾ðÊó¤òÅϤ¹
            test.RotateCube(eulerAngle,axis,true);
        }

        if (Input.GetKeyDown(KeyCode.Space)) {
            // cube¤Î¾õÂÖ¤ò¥ê¥»¥Ã¥È¤¹¤ë¤¿¤á¡¢Test¥¯¥é¥¹¤ÎResetRotate¤ò¸Æ¤Ó½Ð¤¹
            test.ResetRotate();
        }
        if (Input.GetKeyDown(KeyCode.V)) {
            // ³Æ²óž¼´¤Î²óž¤µ¤»¤¿²ó¿ô¤ò¥ê¥»¥Ã¥È¤¹¤ë¤¿¤á¡¢Test¥¯¥é¥¹¤ÎResetAxisCount¤ò¸Æ¤Ó½Ð¤¹
            test.ResetAxisCount(0);
        }
    }
}
´°À®¤·¤¿¤éCube¥ª¥Ö¥¸¥§¥¯¥È¤Ë¥¢¥¿¥Ã¥Á¤·¤Þ¤¹¡£
¥­¡¼ÆþÎϤò¤·¤¿¤È¤­¤ËCube¥ª¥Ö¥¸¥§¥¯¥È¤¬²óž¤¹¤ë¤«¡¢³Îǧ¤ò¤·¤Æ¤ß¤Þ¤·¤ç¤¦¡£
¤½¤ì¤¾¤ìÊ̤Υ¯¥é¥¹¤Ë½ñ¤«¤ì¤Æ¤¤¤ë½èÍý¤¬°ìÏ¢¤Îή¤ì¤Ç·Ò¤¬¤Ã¤Æ¤¤¤ì¤Ð²óžưºî¤ò¤¹¤ë¤Ï¤º¤Ç¤¹¡£

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


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

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

Menu


´ðÁÃ

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

private



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

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