12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using UnityEngine;
- using System.Collections;
- /// <summary>
- /// 动态UI背景图管理器
- /// </summary>
- public class DynamicBackgroundControler : MonoBehaviour
- {
- /// <summary>
- /// 单键
- /// </summary>
- private static DynamicBackgroundControler pInit = null;
- /// <summary>
- /// 背景图
- /// </summary>
- private GameObject mBgPlane;
- /// <summary>
- /// 获取管理者
- /// </summary>
- /// <returns>单键实例</returns>
- public static DynamicBackgroundControler Instance()
- {
- return pInit;
- }
- /// <summary>
- /// 初始化
- /// </summary>
- private void Awake()
- {
- pInit = this;
- //// 切换关卡时不删除
- DontDestroyOnLoad(this);
- }
- /// <summary>
- /// 相机映射图片
- /// </summary>
- private RenderTexture renderTexture;
- /// <summary>
- /// 开始
- /// </summary>
- private void Start()
- {
- //renderTexure赋值
- GameObject _mCamera = this.transform.Find("Camera").gameObject;
- if (_mCamera.GetComponent<AudioListener>() != null)
- {
- Destroy(_mCamera.GetComponent<AudioListener>());
- }
- renderTexture = new RenderTexture(1080, 1920, 24, RenderTextureFormat.ARGB32);
- _mCamera.GetComponent<Camera>().targetTexture = renderTexture;
- mBgPlane = this.transform.Find("BGmian/Plane").gameObject;
- }
- /// <summary>
- /// 相机动态render图片
- /// </summary>
- public RenderTexture CameraRenderTexture
- {
- get { return renderTexture; }
- }
- }
|