ºÇ½ª¹¹¿·¡§
orika_ex_miyako 2020ǯ08·î05Æü(¿å) 01:27:48ÍúÎò
¤³¤Á¤é¤Î¥¯¥é¥¹¤È¼¡¤ÎCubeController¥¯¥é¥¹¤ÎξÊý¤ò°·¤Ã¤Æ°ìÏ¢¤ÎÆ°ºî¤ò¹Ô¤¦¤è¤¦¤ËÀ߷פµ¤ì¤Æ¤¤¤Þ¤¹¡£
¤Þ¤º¤Ï¤³¤Á¤é¤Î¥¯¥é¥¹¤òºîÀ®¤·¤Æ¤¯¤À¤µ¤¤¡£
using System.Collections; using System.Collections.Generic; using UnityEngine; /// <summary> /// ¥ª¥Ö¥¸¥§¥¯¥È¤Î²óž¥Æ¥¹¥ÈÍÑ¥¯¥é¥¹ /// </summary> public class RotateTest : MonoBehaviour { [Header("²óž¤µ¤»¤ë¼´¤È²óž¤µ¤»¤ë²ó¿ô")] public int x; public int y; public int z; /// <summary> /// Cube¤ò²óž¤µ¤»¤ë½èÍý /// </summary> /// <param name="argumentEulerAngle">²óž¤µ¤»¤ë³ÑÅÙ</param> /// <param name="argumentAxis">²óž¤µ¤»¤ë¼´</param> ¡¡ /// <param name="isReverseFlag">Àµ²óž¤«µÕ²óž¤«¤É¤¦¤«¤Î¥Õ¥é¥° ´ðËܤÏfalse¤ÇÀµ²óž</param> public void RotateCube(float argumentEulerAngle, int argumentAxis, bool isReverseFlag = false) { // ²óž¤µ¤»¤¿¤¤¼´¤Î¾ðÊó¤òrotationPos¤ËÂåÆþ Quaternion rotationPos = transform.rotation; Debug.Log(transform.rotation); // µÕ²óž¤µ¤»¤ë¥Õ¥é¥°¤¬ON(true)¤Ê¤é¡¢²óž¤µ¤»¤ë¸þ¤¤òµÕ¤Ë¤¹¤ë if (isReverseFlag) { argumentEulerAngle = -argumentEulerAngle; Debug.Log("Reverse"); } // ²óž¤µ¤»¤ë¼´¤ò·è¤á¤ëʬ´ô ¤¤¤º¤ì¤«¤Îcase¤ËÆþ¤ë // ¼´¤´¤È¤Ë²óž¤·¤¿²ó¿ô¤¬¥«¥¦¥ó¥È¤µ¤ì¤ë switch (argumentAxis) { case 0: // x¼´ x++; rotationPos.x = argumentEulerAngle * x; break; case 1: // y¼´ y++; rotationPos.y = argumentEulerAngle * y; break; case 2: // z¼´ z++; rotationPos.z = argumentEulerAngle * z; break; } // ¾åµ¤Îʬ´ô¤Ç·èÄꤷ¤¿³ÑÅ٤Dz󞤵¤»¤ë // ʬ´ô°Ê³°¤Î£²¤Ä¤Î¼´¤Ï¸µ¡¹¤Î¿ôÃͤ¬¤½¤Î¤Þ¤ÞºÆÅÙÆþ¤ë transform.rotation = Quaternion.Euler(rotationPos.x, rotationPos.y, rotationPos.z); Debug.Log(transform.rotation); } /// <summary> /// Cube¤Î²óž¤ò½é´ü¾õÂÖ¤ËÌ᤹½èÍý /// </summary> public void ResetRotate() { // identity¤Ï¥²¡¼¥à³«»Ï»þ¡ÊÀ¸À®»þ¡Ë¤Î²óž¼´¤Î¾ðÊó¤Î¾õÂÖ transform.rotation = Quaternion.identity; //transform.rotation = Quaternion.Euler(0,0,0); } /// <summary> /// Cube¤Î³Æ²óž¼´¤Î²óž²ó¿ô¤ò0¤ËÌ᤹½èÍý /// </summary> /// <param name="argumentCount"></param> public void ResetAxisCount(int argumentCount) { x = argumentCount; y = argumentCount; z = argumentCount; } }
¤³¤Á¤é¤Î¥¯¥é¥¹¤òCube¥ª¥Ö¥¸¥§¥¯¥È¤Ë¥¢¥¿¥Ã¥Á¤·¤Þ¤¹¡£
¤³¤Î¥¯¥é¥¹¤Ë¤Ï¾¤Î¥¯¥é¥¹¤Î¤è¤¦¤Ê¡¢¥¡¼ÆþÎϤΥ᥽¥Ã¥É¤Ï¤¢¤ê¤Þ¤»¤ó¡£
¥¡¼ÆþÎϤòÊ̤Υ¯¥é¥¹¡ÊCubeController¡Ë¤Ç´ÉÍý¤·¡¢¤³¤Á¤é¤Ç¤Ï²óž¤µ¤»¤ë½èÍý¤Î¤ß¤ò¹Ô¤¦¤è¤¦¤Ë¤·¤Æ¤¤¤ë¤¿¤á¤Ç¤¹¡£
- ¥«¥Æ¥´¥ê¡§
- ¿Ê³Ø/¥¹¥¯¡¼¥ë
- Áí¹ç
¥³¥á¥ó¥È¤ò¤«¤¯