Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sdk-public
unity_sdk_demo
Commits
ccd0e37f
Commit
ccd0e37f
authored
Jan 23, 2026
by
gaorui
Browse files
feat(app): 增加 extra 为 null 时的处理
parent
6df1b893
Changes
3
Show whitespace changes
Inline
Side-by-side
Assets/Scripts/demo/ui/GameSdkManager.cs
View file @
ccd0e37f
...
@@ -89,9 +89,9 @@ public class GameManager : MonoBehaviour
...
@@ -89,9 +89,9 @@ public class GameManager : MonoBehaviour
playerInfo
.
ClassField
=
"滴滴滴答"
;
playerInfo
.
ClassField
=
"滴滴滴答"
;
//Game Extra sample Data(optional)
//Game Extra sample Data(optional)
playerInfo
.
AddExtra
(
"intKey"
,
55
);
//
playerInfo.AddExtra("intKey", 55);
playerInfo
.
AddExtra
(
"longLongKey"
,
66786658787676
);
//
playerInfo.AddExtra("longLongKey", 66786658787676);
playerInfo
.
AddExtra
(
"stringKey"
,
"Hello111"
);
//
playerInfo.AddExtra("stringKey", "Hello111");
HoolaiSdkManager
.
SendEvent
(
EventType
.
EnterServer
,
playerInfo
);
HoolaiSdkManager
.
SendEvent
(
EventType
.
EnterServer
,
playerInfo
);
NativeLogger
.
I
(
"Game_Unity_Log"
,
"clicked EnterServer"
);
NativeLogger
.
I
(
"Game_Unity_Log"
,
"clicked EnterServer"
);
...
@@ -116,12 +116,14 @@ public class GameManager : MonoBehaviour
...
@@ -116,12 +116,14 @@ public class GameManager : MonoBehaviour
ItemId
=
"com.nekki.sf3.cn_1"
,
ItemId
=
"com.nekki.sf3.cn_1"
,
ItemName
=
"礼包0"
,
ItemName
=
"礼包0"
,
CallbackInfo
=
"123456_8888_987654321"
,
CallbackInfo
=
"123456_8888_987654321"
,
NotifyUrl
=
""
,
NotifyUrl
=
""
,
//支付回调地址,默认使用客户端传递的
Count
=
1
,
Count
=
1
,
Currency
=
"CNY"
Currency
=
"CNY"
};
};
payParams
.
AddOptionalParameter
(
"test"
,
"daily_bonus"
);
payParams
.
AddOptionalParameter
(
"player_id"
,
"p-98765"
);
// 2. 添加可选参数
//payParams.AddOptionalParameter("test", "daily_bonus");
//payParams.AddOptionalParameter("player_id", "p-98765");
NativeLogger
.
I
(
"Game_Unity_Log"
,
$"clicked Exit jsonString:
{
payParams
}
"
);
NativeLogger
.
I
(
"Game_Unity_Log"
,
$"clicked Exit jsonString:
{
payParams
}
"
);
HoolaiSdkManager
.
StartPay
(
payParams
);
HoolaiSdkManager
.
StartPay
(
payParams
);
...
...
Assets/Scripts/sdk/core/HoolaiSdkManager.cs
View file @
ccd0e37f
...
@@ -45,6 +45,10 @@ public static class HoolaiSdkManager
...
@@ -45,6 +45,10 @@ public static class HoolaiSdkManager
// ==================== 数据上报 ====================
// ==================== 数据上报 ====================
public
static
void
SendEvent
(
EventType
eventType
,
PlayerInfo
playerInfo
)
public
static
void
SendEvent
(
EventType
eventType
,
PlayerInfo
playerInfo
)
{
{
if
(
playerInfo
.
Extra
==
null
)
{
playerInfo
.
SetExtra
(
string
.
Empty
);
}
string
jsonStr
=
JsonConvert
.
SerializeObject
(
playerInfo
,
new
JsonSerializerSettings
string
jsonStr
=
JsonConvert
.
SerializeObject
(
playerInfo
,
new
JsonSerializerSettings
{
{
NullValueHandling
=
NullValueHandling
.
Include
,
NullValueHandling
=
NullValueHandling
.
Include
,
...
...
Assets/Scripts/sdk/data/PlayerInfo.cs
View file @
ccd0e37f
...
@@ -62,6 +62,14 @@ public class PlayerInfo
...
@@ -62,6 +62,14 @@ public class PlayerInfo
[
JsonIgnore
]
[
JsonIgnore
]
public
string
Extra
=>
_extra
;
public
string
Extra
=>
_extra
;
/// <summary>
/// 设置 Extra 字段的值
/// </summary>
public
void
SetExtra
(
string
value
)
{
_extra
=
value
??
string
.
Empty
;
}
public
void
AddExtra
(
string
key
,
int
value
)
public
void
AddExtra
(
string
key
,
int
value
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment