private void Anchor() { // 横 float horizontal = 0.0f; switch (anchorPosH) { case ANCHOR_POSITION_HORIZONTAL.LEFT: horizontal = 0.0f; break; case ANCHOR_POSITION_HORIZONTAL.MIDDLE: horizontal = 0.5f; break; case ANCHOR_POSITION_HORIZONTAL.RIGHT: horizontal = 1.0f; break; default: break; } // 縦 float vertical = 0.0f; switch (anchorPosV) { case ANCHOR_POSITION_VERTICAL.TOP: vertical = 1.0f; break; case ANCHOR_POSITION_VERTICAL.MIDDLE: vertical = 0.5f; break; case ANCHOR_POSITION_VERTICAL.BOTTOM: vertical = 0.0f; break; default: break; } Vector3 worldPos = CameraUtil.FindCameraForLayer(this.gameObject.layer).ViewportToWorldPoint(new Vector3(horizontal, vertical, 0.0f)); this.gameObject.transform.position = new Vector3(worldPos.x, worldPos.y, this.gameObject.transform.position.z); }
void Start() { if (rayCamera == null) { rayCamera = CameraUtil.FindCameraForLayer(this.gameObject.layer); } if (rayCamera == null) { rayCamera = Camera.main; } collid = this.GetComponent <Collider>(); if (collid == null) { Debug.LogWarning("collider is null. a collider component is required for button processing."); } }
protected virtual void Start() { // 設定ファイルから入力モードの取得 if (ApplicationSetting.Instance.GetString("InputMode").ToLower() == "mouse") { inputType = INPUT_TYPE.MOUSE; } else { inputType = INPUT_TYPE.WTOUCH; } // 自分を描画するカメラを取得 rayCamera = CameraUtil.FindCameraForLayer(this.gameObject.layer); // ボタンテクスチャの設定 if (guiPlate != null && guiPlate.GetComponent <Renderer>() != null) { defaultButtonColor = guiPlate.GetComponent <Renderer>().material.color; } ChangeTexture(false); }