Skip to content

TriggerEncapsulation.UIProperty ​

PlayerUIPropertyExtensions 双端 ​

命名空间 TriggerEncapsulation.UIProperty

csharp
public static class PlayerUIPropertyExtensions

Player类的UI属性扩展方法 提供客户端设置UI属性的功能

方法 ​

SetUIPropertyAsync 仅客户端 ​

csharp
public static Task<bool> SetUIPropertyAsync<TValue>(this Player player, PropertyPlayerUI property, TValue value)

客户端设置UI属性

  • player — 玩家实例
  • property — UI属性
  • value — 属性值

返回: 是否成功发送请求

SetUIPropertiesAsync 仅客户端 ​

csharp
public static Task<bool> SetUIPropertiesAsync(this Player player, Dictionary<PropertyPlayerUI, object> properties)

客户端批量设置UI属性

  • player — 玩家实例
  • properties — 要设置的属性集合

返回: 是否成功发送请求

SetUIPropertyJsonAsync 仅客户端 ​

csharp
public static Task<bool> SetUIPropertyJsonAsync(this Player player, PropertyPlayerUI property, object value)

客户端设置UI属性(便捷方法,自动序列化为JSON)

  • player — 玩家实例
  • property — UI属性
  • value — 属性值(将被序列化为JSON)

返回: 是否成功发送请求

GetUIPropertyAs 仅客户端 ​

csharp
public static TValue GetUIPropertyAs<TValue>(this Player player, PropertyPlayerUI property, TValue defaultValue = default(TValue))

客户端获取UI属性并反序列化为指定类型

  • player — 玩家实例
  • property — UI属性
  • defaultValue — 默认值

返回: 属性值

GetUIPropertyFromJson 仅客户端 ​

csharp
public static TValue GetUIPropertyFromJson<TValue>(this Player player, PropertyPlayerUI property, TValue defaultValue = default(TValue))

客户端获取UI属性的JSON字符串并反序列化

  • player — 玩家实例
  • property — UI属性
  • defaultValue — 默认值

返回: 反序列化后的属性值

UIPropertyBatchSetRequest 双端 ​

命名空间 TriggerEncapsulation.UIProperty

csharp
public class UIPropertyBatchSetRequest

UI属性批量设置请求消息

构造函数 ​

UIPropertyBatchSetRequest 双端 ​

csharp
public UIPropertyBatchSetRequest()

属性 ​

Requests 双端 ​

csharp
public List<UIPropertySetRequest> Requests { get; set; }

UIPropertyMessageHandler 双端 ​

命名空间 TriggerEncapsulation.UIProperty

csharp
public static class UIPropertyMessageHandler

UI属性消息处理器 负责处理来自客户端的UI属性设置请求

方法 ​

Initialize 双端 ​

csharp
public static void Initialize()

初始化UI属性消息处理器

UIPropertySetRequest 双端 ​

命名空间 TriggerEncapsulation.UIProperty

csharp
public class UIPropertySetRequest

UI属性设置请求消息

构造函数 ​

UIPropertySetRequest 双端 ​

csharp
public UIPropertySetRequest()

属性 ​

Property 双端 ​

csharp
public PropertyPlayerUI Property { get; set; }

Value 双端 ​

csharp
public string Value { get; set; }

ValueType 双端 ​

csharp
public string ValueType { get; set; }

UIPropertyUsageExample 双端 ​

命名空间 TriggerEncapsulation.UIProperty

csharp
public static class UIPropertyUsageExample

UI属性系统使用示例 展示如何在TriggerEncapsulation库中使用UI属性扩展功能

方法 ​

Initialize 双端 ​

csharp
public static void Initialize()

初始化示例 - 注册必要的处理器

ClientUsageExample 仅客户端 ​

csharp
public static Task ClientUsageExample()

客户端使用示例

RestoreUIState 仅客户端 ​

csharp
public static void RestoreUIState()

客户端UI状态恢复示例

BadUsageExamples 双端 ​

csharp
public static void BadUsageExamples()

错误使用示例 - 展示应该避免的做法

ServerUsageExample 仅服务端 ​

csharp
public static void ServerUsageExample()

服务端使用示例

SetDefaultUIPropertiesForPlayer 仅服务端 ​

csharp
public static void SetDefaultUIPropertiesForPlayer(Player player)

为新玩家设置默认UI属性