public FOWRender CreateRender(Transform parent) { if (parent == null) { return(null); } FOWRender render = null; // TODO:实际项目中,从这里的资源管理类加载预设 // 为了简单,这里直接从Resource加载 Object prefabs = Resources.Load("Prefabs/FOWRender"); if (prefabs != null) { GameObject mesh = GameObject.Instantiate(prefabs) as GameObject; if (mesh != null) { mesh.transform.parent = parent; render = mesh.gameObject.AddComponent <FOWRender>(); } } if (render != null) { m_renders.Add(render); } return(render); }
public override void Dispose() { Messenger.RemoveListener <int>(MessageName.MN_CHARACTOR_BORN, AddCharactor); for (int i = 0; i < m_revealers.Count; i++) { IFOWRevealer revealer = m_revealers[i]; if (revealer != null) { revealer.Release(); } } m_revealers.Clear(); for (int i = 0; i < m_renders.Count; i++) { FOWRender render = m_renders[i]; if (render != null) { render.enabled = false; UnityEngine.Object.Destroy(render.gameObject); } } m_renders.Clear(); m_mapFOWRender = null; FOWSystem.instance.DestroySelf(); }
private void ActivateRender(FOWRender render, bool active) { if (render != null) { render.Activate(active); } }
public MapFOWRender(Transform mapParent) { FOWRender render = FOWLogic.instance.CreateRender(mapParent); if (render != null) { // TODO:实际项目中,自己根据场景地图设置中心点位置 // 这里为了简单,直接居中 float fCenterX = 0f; float fCenterZ = 0f; float scale = FOWSystem.instance.WorldSize / 128f * 2.56f; render.transform.position = new Vector3(fCenterX, 0f, -fCenterZ); render.transform.eulerAngles = new Vector3(-90f, 180f, 0f); render.transform.localScale = new Vector3(scale, scale, 1f); } }
public MiniMapFOWRender(Transform mapParent, Camera fowCamera, UITexture fowRenderTex) { FOWRender render = FOWLogic.instance.CreateRender(mapParent); if (render != null) { //m_transform = render.transform.parent; render.transform.localPosition = Vector3.zero; render.transform.localEulerAngles = new Vector3(0f, 180f, 0f); render.transform.localScale = Vector3.one; render.gameObject.layer = mapParent.gameObject.layer; m_renderer = render.GetComponent <MeshRenderer>(); } m_renderTexture = RenderTexture.GetTemporary(fowRenderTex.width, fowRenderTex.height); fowCamera.transform.parent = null; fowCamera.transform.localScale = Vector3.one; fowCamera.transform.localPosition = new Vector3(-10000, 0, 0); fowCamera.targetTexture = m_renderTexture; m_fowRenderTex = fowRenderTex; m_fowRenderTex.mainTexture = m_renderTexture; }