Class UnityViewBase
Abstract base class for Unity-based views that provides common view lifecycle management.
Implements IViewBase for show/hide operations and IFoundationSettings for foundation integration.
Includes automatic cleanup of disposable resources on destruction to prevent memory leaks.
Inherits from MonoBehaviour to enable Unity component functionality and GameObject integration.
Namespace: Serenity.Global.Infrastructure.Views
Assembly: Serenity.UnityGlobal.Infrastructure.dll
Syntax
public abstract class UnityViewBase : MonoBehaviour, IViewBase, IFoundationSettings
Constructors
UnityViewBase()
Declaration
protected UnityViewBase()
Fields
_disposables
Declaration
protected readonly List<IDisposable> _disposables
Field Value
| Type | Description |
|---|---|
| List<IDisposable> | Collection of disposable resources that will be automatically cleaned up when the view is destroyed. |
_guid
Declaration
protected string _guid
Field Value
| Type | Description |
|---|---|
| string | Globally unique identifier for this view type used for serialization and foundation settings. |
_id
Declaration
protected string _id
Field Value
| Type | Description |
|---|---|
| string | Unique identifier for this view instance used for foundation management and tracking. |
_logService
Declaration
protected ILogService _logService
Field Value
| Type | Description |
|---|---|
| ILogService |
Properties
Guid
Gets or sets the globally unique identifier for this view type. Used for foundation settings serialization and type identification.
Declaration
public string Guid { get; set; }
Property Value
| Type | Description |
|---|---|
| string | Globally unique identifier string |
Id
Gets or sets the unique identifier for this view instance.
Declaration
public string Id { get; set; }
Property Value
| Type | Description |
|---|---|
| string | Unique identifier string |
LogService
Gets or sets the logging service for this view. Used for logging view-related events and errors.
Declaration
public ILogService LogService { get; set; }
Property Value
| Type | Description |
|---|---|
| ILogService | Logging service instance |
Methods
Hide()
Hides this view by deactivating the associated GameObject and logging the operation.
Virtual method that can be overridden by derived classes to implement custom hide behavior.
Automatically deactivates the GameObject to make the view invisible in the scene.
Declaration
public virtual void Hide()
Initialize(ILogService)
Initializes the view with the provided logging service.
Declaration
public void Initialize(ILogService logService)
Parameters
| Type | Name | Description |
|---|---|---|
| ILogService | logService | The logging service to be used by the view. |
OnDestroy()
Unity lifecycle method called when the view GameObject is destroyed.
Automatically disposes all registered disposable resources to prevent memory leaks.
Derived classes should call base.OnDestroy() if they override this method.
Declaration
protected virtual void OnDestroy()
Show()
Shows this view by activating the associated GameObject and logging the operation.
Virtual method that can be overridden by derived classes to implement custom show behavior.
Automatically activates the GameObject to make the view visible in the scene.
Declaration
public virtual void Show()
ToString()
Returns a string representation of this view instance including ID and GUID for debugging.
Provides essential identification information for logging and diagnostic purposes.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | String containing the view type, ID, and GUID values |