public static LightingMeshRenderer Pull(Object source) { LightingManager2D manager = LightingManager2D.Get(); foreach (LightingMeshRenderer id in LightingMeshRenderer.GetList()) { if (id.owner == source) { id.gameObject.SetActive(true); return(id); } } foreach (LightingMeshRenderer id in LightingMeshRenderer.GetList()) { if (id.free == true) { id.free = false; id.owner = source; id.gameObject.SetActive(true); return(id); } } return(AddBuffer(source)); }
// void LateUpdate() { // UpdatePosition(); // } // Management static public LightingMeshRenderer AddBuffer(Object source) { // LightingManager2D manager = LightingManager2D.Get(); // if (manager.fixedLightBufferSize) { // textureSize = LightingManager2D.GetTextureSize(manager.fixedLightTextureSize); // } MeshRendererManager manager = Get(); if (manager == null) { Debug.LogError("Lighting Manager Instance is Out-Dated."); Debug.LogError("Try Re-Initializing 'Lighting Manager 2D' Component"); return(null); } GameObject buffer = new GameObject(); buffer.name = "Mesh Renderer " + (LightingMeshRenderer.GetCount() + 1); buffer.transform.parent = manager.transform; buffer.layer = LightingManager2D.lightingLayer; LightingMeshRenderer lightingBuffer = buffer.AddComponent <LightingMeshRenderer> (); lightingBuffer.Initialize(); lightingBuffer.owner = source; lightingBuffer.free = false; //lightingBuffer.lightSource = light; // Unnecessary? //lightingBuffer.free = false; //lightingBuffer.bufferCamera.orthographicSize = light.lightSize; return(lightingBuffer); }
public void DrawMesh() { //Graphics.DrawMesh(LightingManager2D.GetRenderMesh(), Matrix4x4.TRS(position, Quaternion.Euler(0, 0, rotation), scale2), GetMaterial(), 0); if (GetMaterial() && applyAdditive) { LightingMeshRenderer lightingMesh = MeshRendererManager.Pull(this); lightingMesh.UpdateAsLightSprite(this); } }
public void DrawMesh() { if (meshMode.enable == false) { return; } LightingMeshRenderer lightingMesh = MeshRendererManager.Pull(this); if (lightingMesh != null) { lightingMesh.UpdateLightSprite(this, meshMode); } }
// void LateUpdate() { // UpdatePosition(); // } // Management static public LightingMeshRenderer AddBuffer(Object source) { // LightingManager2D manager = LightingManager2D.Get(); // if (manager.fixedLightBufferSize) { // textureSize = LightingManager2D.GetTextureSize(manager.fixedLightTextureSize); // } MeshRendererManager manager = Get(); if (manager == null) { Debug.LogError("Lighting Manager Instance is Out-Dated."); Debug.LogError("Try Re-Initializing 'Lighting Manager 2D' Component"); return(null); } GameObject buffer = new GameObject(); buffer.name = "Mesh Renderer (Id :" + (LightingMeshRenderer.GetCount() + 1) + ")"; buffer.transform.parent = manager.transform; if (Lighting2D.ProjectSettings.managerInternal == LightingSettings.ManagerInternal.HideInHierarchy) { buffer.hideFlags = HideFlags.HideInHierarchy; } else { buffer.hideFlags = HideFlags.None; } LightingMeshRenderer lightingBuffer2D = buffer.AddComponent <LightingMeshRenderer> (); lightingBuffer2D.Initialize(); lightingBuffer2D.owner = source; lightingBuffer2D.free = false; return(lightingBuffer2D); }
void DrawAdditiveLights() { foreach (LightingSource2D id in LightingSource2D.GetList()) { if (id.buffer == null) { continue; } if (id.isActiveAndEnabled == false) { continue; } if (id.buffer.bufferCamera == null) { continue; } if (id.InCamera() == false) { continue; } if (id.additive == false) { continue; } if (id.buffer.GetAdditiveMaterial()) { LightingMeshRenderer lightingMesh = MeshRendererManager.Pull(id); lightingMesh.UpdateAsLightSource(id); } } }