//外部から回転をするときに使用 //public float deg; //回転角度 void Awake() { //コンポーネント引数から初期面位置指定処理 if (serSur == "front") thissur = sur.front; else if (serSur == "right") thissur = sur.right; else if (serSur == "left") thissur = sur.left; else if (serSur == "top") thissur = sur.top; else if (serSur == "bottom") thissur = sur.bottom; else if (serSur == "back") thissur = sur.back; else {//ありえないはず thissur = sur.none; Debug.LogError ("Error"); } }
private void changesur(sur nextsur) { //算出する必要のある数値 Vector3 axis = Vector3.zero; //回転軸 float x = 0; //座標 float y = 0; float z = 0; //前処理 if (thissur == sur.front) z = min; else if (thissur == sur.back) z = max; else if (thissur == sur.right) x = min; else if (thissur == sur.left) x = max; else if (thissur == sur.top) y = max; else if (thissur == sur.bottom) y = min; else Debug.LogError ("Error"); if (nextsur == sur.front) z = -BGS / 2; else if (nextsur == sur.back) z = BGS / 2; else if (nextsur == sur.right) x = -BGS / 2; else if (nextsur == sur.left) x = BGS / 2; else if (nextsur == sur.top) y = BGS / 2; else if (nextsur == sur.bottom) y = -BGS / 2; else Debug.LogError ("Error"); if (thissur == sur.front) { if (nextsur == sur.right) { axis = Vector3.up; y = Mathf.Round(gameObject.transform.position.y*10.0F)/10.0F; } else if (nextsur == sur.left) { axis = Vector3.down; y = Mathf.Round(gameObject.transform.position.y*10.0F)/10.0F; } else if (nextsur == sur.top) { axis = Vector3.right; x = Mathf.Round(gameObject.transform.position.x*10.0F)/10.0F; } else if (nextsur == sur.bottom) { axis = Vector3.left; x = Mathf.Round(gameObject.transform.position.x*10.0F)/10.0F; } else { Debug.LogError ("Error"); } } else if (thissur == sur.back) { if (nextsur == sur.right) { axis = Vector3.down; y = Mathf.Round(gameObject.transform.position.y*10.0F)/10.0F; } else if (nextsur == sur.left) { axis = Vector3.up; y = Mathf.Round(gameObject.transform.position.y*10.0F)/10.0F; } else if (nextsur == sur.top) { axis = Vector3.left; x = Mathf.Round(gameObject.transform.position.x*10.0F)/10.0F; } else if (nextsur == sur.bottom) { axis = Vector3.right; x = Mathf.Round(gameObject.transform.position.x*10.0F)/10.0F; } else { Debug.LogError ("Error"); } } else if (thissur == sur.right) { if (nextsur == sur.front) { axis = Vector3.down; y = Mathf.Round(gameObject.transform.position.y*10.0F)/10.0F; } else if (nextsur == sur.back) { axis = Vector3.up; y = Mathf.Round(gameObject.transform.position.y*10.0F)/10.0F; } else if (nextsur == sur.top) { axis = Vector3.back; z = Mathf.Round(gameObject.transform.position.z*10.0F)/10.0F; } else if (nextsur == sur.bottom) { axis = Vector3.forward; z = Mathf.Round(gameObject.transform.position.z*10.0F)/10.0F; } else { Debug.LogError ("Error"); } } else if (thissur == sur.left) { if (nextsur == sur.front) { axis = Vector3.up; y = Mathf.Round(gameObject.transform.position.y*10.0F)/10.0F; } else if (nextsur == sur.back) { axis = Vector3.down; y = Mathf.Round(gameObject.transform.position.y*10.0F)/10.0F; } else if (nextsur == sur.top) { axis = Vector3.forward; z = Mathf.Round(gameObject.transform.position.z*10.0F)/10.0F; } else if (nextsur == sur.bottom) { axis = Vector3.back; z = Mathf.Round(gameObject.transform.position.z*10.0F)/10.0F; } else { Debug.LogError ("Error"); } } else if (thissur == sur.top) { if (nextsur == sur.front) { axis = Vector3.left; x = Mathf.Round(gameObject.transform.position.x*10.0F)/10.0F; } else if (nextsur == sur.back) { axis = Vector3.right; x = Mathf.Round(gameObject.transform.position.x*10.0F)/10.0F; } else if (nextsur == sur.right) { axis = Vector3.forward; z = Mathf.Round(gameObject.transform.position.z*10.0F)/10.0F; } else if (nextsur == sur.left) { axis = Vector3.back; z = Mathf.Round(gameObject.transform.position.z*10.0F)/10.0F; } else { Debug.LogError ("Error"); } } else if (thissur == sur.bottom) { if (nextsur == sur.front) { axis = Vector3.right; x = Mathf.Round(gameObject.transform.position.x*10.0F)/10.0F; } else if (nextsur == sur.back) { axis = Vector3.left; x = Mathf.Round(gameObject.transform.position.x*10.0F)/10.0F; } else if (nextsur == sur.right) { axis = Vector3.back; z = Mathf.Round(gameObject.transform.position.z*10.0F)/10.0F; } else if (nextsur == sur.left) { axis = Vector3.forward; z = Mathf.Round(gameObject.transform.position.z*10.0F)/10.0F; } else { Debug.LogError ("Error"); } } //移動 thissur = nextsur; //現在面を更新 gameObject.transform.Rotate (axis, 90, Space.World); //90度回転 gameObject.transform.position = new Vector3 (x, y, z);//面移動後初期位置 //微調整 処理に負荷となる場合には削除してもかまわない------------------------------------------------------- ajustRotation (); //------------------------------------------------------------------------------------------------------------------------ }
void Awake() { //定数代入------------------------------------------------------------------------- //画像サイズ設定 gos = GAMEOBJECTSIZE; bgs = BACKGROUNDSIZE; //移動初期値設定 dx = MOVESPEED; //移動量 //--------------------------------------------------------------------------------------- dir = Vector3.down; //移動方向 //画面切り替え境界位置 max = + (bgs/ 2) - (gos / 2); //0.1単位 min = - (bgs/ 2) + (gos / 2); //0.1単位 //初期位置から初期面位置設定 if (gameObject.transform.position.x == bgs / 2) thissur = sur.left; else if(gameObject.transform.position.x == -bgs/2) thissur = sur.right; else if(gameObject.transform.position.y == bgs/2) thissur = sur.top; else if(gameObject.transform.position.y == -bgs/2) thissur = sur.bottom; else if(gameObject.transform.position.z == bgs/2) thissur = sur.back; else if(gameObject.transform.position.z == -bgs/2) thissur = sur.front; else {//ありえないはず thissur = sur.none; Debug.LogError ("Error"); } }