网演高层钦州
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

56 lines
1.7 KiB

using AX.MessageSystem;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class QuadCamsManager : MonoBehaviour {
private static QuadCamsManager instance;
public static QuadCamsManager Instance
{
get
{
return instance;
}
}
void Awake()
{
instance = this;
}
public GameObject quadCamPre;
// Use this for initialization
void Start () {
quadCamPre = Resources.Load("4GTransfer/QuadCam") as GameObject;
//MessageDispatcher.AddListener("QuadrupleMode", DeleteAllCams); 测试:暂时不需要删除所有四分屏
//MessageDispatcher.AddListener("QuadrupleMode", DisableAllCams);
}
/// <summary>
/// 生成新的四分相机
/// </summary>
/// <param name="obj"></param>
public void InstantiateCamera(CloneGameObjInfo info,RenderTexture texture)
{
GameObject cam = Instantiate(quadCamPre, transform);
cam.name = "QuadCam-" + cam.transform.GetSiblingIndex().ToString();
cam.GetComponent<Camera>().targetTexture = texture;
cam.GetComponent<QuadCamera>().SetTarget(info);
}
/// <summary>
/// 关闭四分屏模式,删除所有相机
/// </summary>
/// <param name="obj"></param>
void DeleteAllCams(IMessage obj)
{
var isQuad = (bool)obj.Data;
if (isQuad == false) //如果关闭四分屏模式,删除所有相机
{
for(int i = 0; i < transform.childCount; i++)
{
Destroy(transform.GetChild(i).gameObject);
}
}
}
}