Beispiel #1
0
    static public LightingMainBuffer2D Get(CameraSettings cameraSettings)
    {
        if (cameraSettings.GetCamera() == null)
        {
            return(null);
        }

        foreach (LightingMainBuffer2D mainBuffer in List)
        {
            if (mainBuffer.cameraSettings.GetCamera() == cameraSettings.GetCamera() && mainBuffer.cameraSettings.bufferID == cameraSettings.bufferID)
            {
                return(mainBuffer);
            }
        }

        if (Lighting2D.BufferPresets.Length <= cameraSettings.bufferID)
        {
            Debug.LogWarning("Lighting2D: Not enough buffer settings initialized");

            return(null);
        }

        Buffers.Get();

        LightingMainBuffer2D buffer = new LightingMainBuffer2D();

        buffer.cameraSettings = cameraSettings;

        Rendering.LightingMainBuffer.InitializeRenderTexture(buffer);

        return(buffer);
    }
	void LateUpdate() {
		if (Lighting2D.disable) {
			return;
		}

		Camera camera = Buffers.Get().GetCamera();

		UpdateInternal();
		
		if (Lighting2D.Profile.qualitySettings.updateMethod == LightingSettings.UpdateMethod.LateUpdate) {
			RenderLoop();
			
			camera.enabled = false;
		} else {
			camera.enabled = true;
		}
	}
	public void Awake() {
		if (instance != null && instance != this) {

			switch(Lighting2D.ProjectSettings.managerInstance) {
				case LightingSettings.ManagerInstance.Static:
				case LightingSettings.ManagerInstance.DontDestroyOnLoad:
					
					Debug.LogWarning("Smart Lighting2D: Lighting Manager duplicate was found, new instance destroyed.", gameObject);

					foreach(LightingManager2D manager in Object.FindObjectsOfType(typeof(LightingManager2D))) {
						if (manager != instance) {
							manager.DestroySelf();
						}
					}

					return; // Cancel Initialization

				case LightingSettings.ManagerInstance.Dynamic:
					instance = this;
					
					Debug.LogWarning("Smart Lighting2D: Lighting Manager duplicate was found, old instance destroyed.", gameObject);

					foreach(LightingManager2D manager in Object.FindObjectsOfType(typeof(LightingManager2D))) {
						if (manager != instance) {
							manager.DestroySelf();
						}
					}
				break;
			}
			

		}

		LightingManager2D.initialized = false;
		SetupProfile();

		if (Application.isPlaying) {
			if (Lighting2D.ProjectSettings.managerInstance == LightingSettings.ManagerInstance.DontDestroyOnLoad) {
				DontDestroyOnLoad(instance.gameObject);
			}
		}
		
		Buffers.Get();
	}
		static public void OnSceneView(SceneView sceneView) {
			LightingManager2D manager = LightingManager2D.Get();
	
			if (manager.IsSceneView() == false) {
				return;
			}

			ForceUpdate();

			manager.UpdateLoop();
			manager.RenderLoop();

			Buffers lightingCamera = Buffers.Get();;

			if (lightingCamera != null) {
				lightingCamera.enabled = false;
				lightingCamera.enabled = true;
			}
		}
Beispiel #5
0
    public void Initialize(LightingMainBuffer2D mainBuffer)
    {
        gameObject.transform.parent = Buffers.Get().transform;

        meshRenderer = gameObject.AddComponent <MeshRenderer>();
        meshRenderer.sharedMaterial = mainBuffer.GetMaterial();

        BufferPreset bufferPreset = mainBuffer.GetBufferPreset();

        bufferPreset.sortingLayer.ApplyToMeshRenderer(meshRenderer);

        // Disable Mesh Renderer Settings
        meshRenderer.shadowCastingMode         = UnityEngine.Rendering.ShadowCastingMode.Off;
        meshRenderer.receiveShadows            = false;
        meshRenderer.lightProbeUsage           = UnityEngine.Rendering.LightProbeUsage.Off;
        meshRenderer.reflectionProbeUsage      = UnityEngine.Rendering.ReflectionProbeUsage.Off;
        meshRenderer.allowOcclusionWhenDynamic = false;

        UpdatePosition();

        meshFilter      = gameObject.AddComponent <MeshFilter>();
        meshFilter.mesh = LightingRender2D.GetMesh();
    }