playerにも索敵範囲を作ってどっちのほうに敵がいるのか表示
小画面表示
Cameraのprefabを作り名前をSubCameraとしておく
CameraのInspector>Camera>ProjectionをOrthographicにすると歪みのない映像になる
Perspective

Orthographic

PlayerContoroller.csの
上部に
public GameObject SubCamera ;
public Vector3 cameraPos;
void Start () { }内に
/*小画面表示*/
Vector3 cameraPos = new Vector3 (0, 0, 0);
//GameObject SubCameraObj = Instantiate(SubCamera,cameraPos, Quaternion.identity) as GameObject;//向き補正
GameObject SubCameraObj = Instantiate(SubCamera) as GameObject;//単純にプレファブ追加
SubCameraObj.transform.parent=transform;
SubCameraObj.transform.localPosition = new Vector3 (0, 10f, 0);
Camera camera1 = SubCameraObj.GetComponent
();
camera1.rect = new Rect(0.8f, 0.4f, 0.2F, 0.3f);
camera1.backgroundColor = Color.blue;
/*小画面表示*/
追加後
Inspector欄のSubCameraに先ほど作ったprefabを設定する
Depthの値を変更して、見える順序を決める
Depthの値をMainCameraが1 SubCameraが2とすると、SubCameraの映像が見えるが
逆だと見えない・・・・
**********見本**************
/* マルチ画面テスト */
GameObject obj1 = new GameObject("Camera(Left)");
Camera camera1 = obj1.AddComponent();
camera1.rect = new Rect(0, 0, 0.5F, 1);
camera1.backgroundColor = Color.blue;
GameObject obj2 = new GameObject("Camera(Right)");
Camera camera2 = obj2.AddComponent();
camera2.rect = new Rect(0.5F, 0, 0.5F, 1);
camera2.backgroundColor = Color.red;
/* マルチ画面 */
**********見本**************
- 関連記事
-
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 2017/01/03(火) 18:00:00|
- Unity
-
| トラックバック:0
-
| コメント:0