/// <summary> /// Called by framework. Do not call directly. /// </summary> protected override void OnDestroy() { SceneManager.UnregisterCanvas(this); Mouse.OnLeftButtonDown -= OnLeftMouseDown; Mouse.OnLeftButtonUp -= OnLeftMouseUp; Mouse.OnWindowLeave -= OnWindowLeave; Mouse.OnMove -= OnMouseMove; Input.OnKey -= OnKey; if (_targetMaterial != null) { if (TargetEntity != null && TargetEntity.Exists && _originalMaterial != null) { TargetEntity.Material = _originalMaterial; } _targetMaterial.Release(); _targetMaterial.Dispose(); } if (TargetTexture != null) { TargetTexture.Destroy(); } }
/// <summary> /// Set this Canvas up to draw the UI onto another Entity. /// </summary> /// <returns><c>true</c>, if target entity was setup correctly, <c>false</c> otherwise.</returns> /// <param name="target">Target.</param> /// <param name="targetTexture">Target texture.</param> internal bool SetupTargetEntity(Entity target, Graphic targetTexture) { if (target == null || targetTexture == null) { return(false); } if (TargetTexture != null) { TargetTexture.Destroy(); } TargetTexture = targetTexture; return(SetupRenderMaterial(target)); }
/// <summary> /// Called by framework. Do not call directly. /// </summary> public override void OnDestroy() { Mouse.OnLeftButtonDown -= OnLeftMouseDown; Mouse.OnLeftButtonUp -= OnLeftMouseUp; Mouse.OnWindowLeave -= OnWindowLeave; Mouse.OnMove -= OnMouseMove; Input.OnKey -= OnKey; if (_targetMaterial != null) { if (TargetEntity != null && TargetEntity.Exists && _originalMaterial != null) { TargetEntity.Material = _originalMaterial; } _targetMaterial.Release(); _targetMaterial.Dispose(); } if (TargetTexture != null) { TargetTexture.Destroy(); } }