protected virtual void TryCheckSustainedChildrens(bool p_force = false) { if (_isChildrensDirty || p_force) { _isChildrensDirty = false; //Invalidate constant repaint based in childrens var v_requireConstantRepaint = false; foreach (var _sustainedElement in _sustainedChildrenElements) { if (!_sustainedElement.IsDestroyed()) { v_requireConstantRepaint = v_requireConstantRepaint || _sustainedElement.RequiresConstantRepaint; if (v_requireConstantRepaint) { break; } } } _childrenNeedsConstantRepaint = v_requireConstantRepaint; //We must invalidate all SustainedCanvas Parents var v_sustainedParent = FindSustainedCanvasParent(this); if (v_sustainedParent != null) { v_sustainedParent.TryCheckSustainedChildrens(true); } else { SustainedPerformanceManager.MarkDynamicElementsDirty(); } } }
//Canvas Rebuild Listener for WorldSpace Canvas public void OnCanvasRebuild() { //We must invalidate buffer when in WorldSpace if (!IsScreenCanvasMember()) { SustainedPerformanceManager.Invalidate(this); } }
protected override void OnEnable() { FindRootCanvasParent(); if (m_autoCalculateCullingMask) { RecalculateCullingMask(); } SustainedPerformanceManager.RegisterDynamicElement(this); base.OnEnable(); }
/*protected virtual void HandleOnAfterWaitingToPrepareRenderBuffer(int p_invalidCullingMask) * { * SetViewActive(SustainedPerformanceManager.IsCameraViewInvalid(this, p_invalidCullingMask)); * }*/ protected virtual void HandleOnAfterDrawBuffer(Dictionary <int, RenderTexture> p_renderBuffersDict) { if (m_useRenderBuffer && !SustainedPerformanceManager.IsCameraViewInvalid(this)) { var v_camera = Camera; if (v_camera != null) { v_camera.enabled = false; } } }
protected override void OnBeforeTransformHasChanged() { if (m_forceInvalidateWhenChanged || !IsScreenCanvasMember()) { SustainedPerformanceManager.Invalidate(this); } else { SustainedPerformanceManager.Refresh(this); } }
protected virtual void Start() { _started = true; if (SustainedPerformanceManager.IsHighPerformanceActive()) { HandleOnSetHighPerformance(true); } else { HandleOnSetLowPerformance(); } }
protected virtual void OnDisable() { if (IsScreenCanvasMember()) { SustainedPerformanceManager.Refresh(); } else { SustainedPerformanceManager.Invalidate(this); } SustainedPerformanceManager.UnregisterDynamicElement(this); UnregisterEvents(); SetViewActive(!Application.isPlaying); }
protected virtual void OnEnable() { SustainedPerformanceManager.RegisterDynamicElement(this); RegisterEvents(); if (_started) { if (SustainedPerformanceManager.IsHighPerformanceActive()) { HandleOnSetHighPerformance(true); } else { HandleOnSetLowPerformance(); } } }
protected virtual void TryInitRenderBuffer() { if (Application.isPlaying) { if (m_useRenderBuffer) { var v_bufferCamera = Camera; if (v_bufferCamera != null) { var v_renderTexture = SustainedPerformanceManager.GetRenderBuffer(m_renderBufferIndex); if (v_bufferCamera.targetTexture != v_renderTexture) { v_bufferCamera.targetTexture = v_renderTexture; } } } } }
public virtual void MarkDynamicElementDirty() { var v_executed = false; if (IsScreenCanvasMember()) { var v_canvasView = GetSustainedCanvasParent(); if (v_canvasView != null) { v_executed = true; v_canvasView.MarkDynamicElementDirty(); } } if (!v_executed) { SustainedPerformanceManager.MarkDynamicElementsDirty(); } }
protected virtual void ApplyRenderBufferImmediate() { TryCreateClearTexture(); var v_renderBuffer = SustainedPerformanceManager.GetRenderBuffer(m_renderBufferIndex); //Setup RenderBuffer if (v_renderBuffer != null) { if (v_renderBuffer != texture) { texture = v_renderBuffer; } } //Apply clear texture else { ClearTexture(); } RecalculateRectUV(m_uvBasedOnScreenRect); }
protected override void OnDestroy() { base.OnDestroy(); ClearRenderBuffer(); SustainedPerformanceManager.Invalidate(this); }
protected override void HandleOnSetHighPerformance(bool p_invalidateBuffer) { //We only want to invalidate this canvas if is SelfRequired Constant Repaint TryCheckSustainedChildrens(); if (IsScreenCanvasMember()) { /*if (SustainedPerformanceManager.IsWaitingRenderBuffer) * { * //Register to invalidate After DrawBuffer * RegisterBufferEvents(); * }*/ var v_viewIsActive = SustainedPerformanceManager.UseSafeRefreshMode; if (!v_viewIsActive) { v_viewIsActive = p_invalidateBuffer || SustainedPerformanceManager.RequiresConstantRepaint || SustainedPerformanceManager.IsCanvasViewInvalid(this); } SetViewActive(v_viewIsActive); } //WorldSpace Canvas else { var v_isViewActive = p_invalidateBuffer || SustainedPerformanceManager.RequiresConstantBufferRepaint; if (!v_isViewActive) { v_isViewActive = !UseRenderBuffer; } SetViewActive(v_isViewActive); } }
public virtual void MarkDynamicElementDirty() { SustainedPerformanceManager.MarkDynamicElementsDirty(); }
protected override void OnDisable() { SustainedCanvasView.UnregisterDynamicElement(this); SustainedPerformanceManager.UnregisterDynamicElement(this); base.OnDisable(); }
protected override void HandleOnSetLowPerformance() { SetViewActive(SustainedPerformanceManager.RequiresConstantBufferRepaint && SustainedPerformanceManager.IsCameraViewInvalid(this)); }
protected override void HandleOnSetHighPerformance(bool p_invalidateBuffer) { var v_isViewActive = (p_invalidateBuffer || SustainedPerformanceManager.RequiresConstantBufferRepaint) && SustainedPerformanceManager.IsCameraViewInvalid(this); if (!v_isViewActive) { v_isViewActive = !m_useRenderBuffer; } SetViewActive(v_isViewActive); }
protected virtual void Awake() { _isViewActive = SustainedPerformanceManager.IsHighPerformanceActive(); RegisterRenderView(); }