Skip to content

Commit 702efd1

Browse files
committed
feat(payment): 添加 WebGL 和 PC 平台支付组件配置
增加 m_componentWebGLType 和 m_componentPCType 字段, Awake 中添加 UNITY_WEBGL 和 UNITY_STANDALONE_* 宏匹配, Inspector 同步新增 WebGL 和 PC 平台类型选择下拉框。
1 parent b139261 commit 702efd1

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

Editor/PaymentComponentInspector.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public sealed class PaymentComponentInspector : ComponentTypeComponentInspector
2121
{
2222
private GUIContent m_componentAndroidTypeGUIContent = new GUIContent("Android平台支付组件");
2323
private GUIContent m_componentIOSTypeGUIContent = new GUIContent("iOS平台支付组件");
24+
private GUIContent m_componentWebGLTypeGUIContent = new GUIContent("WebGL平台支付组件");
25+
private GUIContent m_componentPCTypeGUIContent = new GUIContent("PC平台支付组件");
2426

2527
private SerializedProperty ComponentAndroidType = null;
2628
private string[] ComponentAndroidTypeNames = null;
@@ -30,6 +32,14 @@ public sealed class PaymentComponentInspector : ComponentTypeComponentInspector
3032
private string[] ComponentIOSTypeNames = null;
3133
private int ComponentIOSTypeNameIndex = 0;
3234

35+
private SerializedProperty ComponentWebGLType = null;
36+
private string[] ComponentWebGLTypeNames = null;
37+
private int ComponentWebGLTypeNameIndex = 0;
38+
39+
private SerializedProperty ComponentPCType = null;
40+
private string[] ComponentPCTypeNames = null;
41+
private int ComponentPCTypeNameIndex = 0;
42+
3343
public override void OnInspectorGUI()
3444
{
3545
base.OnInspectorGUI();
@@ -53,6 +63,22 @@ public override void OnInspectorGUI()
5363
ComponentIOSTypeNameIndex = componentIOSTypeNameIndex;
5464
ComponentIOSType.stringValue = componentIOSTypeNameIndex <= 0 ? null : ComponentIOSTypeNames[componentIOSTypeNameIndex];
5565
}
66+
67+
EditorGUILayout.LabelField(m_componentWebGLTypeGUIContent);
68+
int componentWebGLTypeNameIndex = EditorGUILayout.Popup("Component WebGL Type", ComponentWebGLTypeNameIndex, ComponentWebGLTypeNames);
69+
if (componentWebGLTypeNameIndex != ComponentWebGLTypeNameIndex)
70+
{
71+
ComponentWebGLTypeNameIndex = componentWebGLTypeNameIndex;
72+
ComponentWebGLType.stringValue = componentWebGLTypeNameIndex <= 0 ? null : ComponentWebGLTypeNames[componentWebGLTypeNameIndex];
73+
}
74+
75+
EditorGUILayout.LabelField(m_componentPCTypeGUIContent);
76+
int componentPCTypeNameIndex = EditorGUILayout.Popup("Component PC Type", ComponentPCTypeNameIndex, ComponentPCTypeNames);
77+
if (componentPCTypeNameIndex != ComponentPCTypeNameIndex)
78+
{
79+
ComponentPCTypeNameIndex = componentPCTypeNameIndex;
80+
ComponentPCType.stringValue = componentPCTypeNameIndex <= 0 ? null : ComponentPCTypeNames[componentPCTypeNameIndex];
81+
}
5682
}
5783
EditorGUI.EndDisabledGroup();
5884

@@ -66,8 +92,12 @@ protected override void Enable()
6692
base.Enable();
6793
ComponentAndroidType = serializedObject.FindProperty("m_componentAndroidType");
6894
ComponentIOSType = serializedObject.FindProperty("m_componentIOSType");
95+
ComponentWebGLType = serializedObject.FindProperty("m_componentWebGLType");
96+
ComponentPCType = serializedObject.FindProperty("m_componentPCType");
6997
RefreshTypeNames(ComponentAndroidType, ref ComponentAndroidTypeNames, ref ComponentAndroidTypeNameIndex, typeof(IPaymentManager));
7098
RefreshTypeNames(ComponentIOSType, ref ComponentIOSTypeNames, ref ComponentIOSTypeNameIndex, typeof(IPaymentManager));
99+
RefreshTypeNames(ComponentWebGLType, ref ComponentWebGLTypeNames, ref ComponentWebGLTypeNameIndex, typeof(IPaymentManager));
100+
RefreshTypeNames(ComponentPCType, ref ComponentPCTypeNames, ref ComponentPCTypeNameIndex, typeof(IPaymentManager));
71101
}
72102

73103
protected override void RefreshTypeNames()

Runtime/PaymentComponent.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class PaymentComponent : GameFrameworkComponent
2323
private IPaymentManager _paymentManager;
2424
[SerializeField] private string m_componentAndroidType = "GameFrameX.Payment.Google.Runtime.GooglePaymentManager";
2525
[SerializeField] private string m_componentIOSType = "GameFrameX.Payment.Apple.Runtime.ApplePaymentManager";
26+
[SerializeField] private string m_componentWebGLType = "GameFrameX.Payment.WebGL.Runtime.WebGLPaymentManager";
27+
[SerializeField] private string m_componentPCType = "GameFrameX.Payment.PC.Runtime.PCPaymentManager";
2628

2729
/// <summary>
2830
/// 购买成功事件
@@ -69,6 +71,10 @@ protected override void Awake()
6971
componentType = m_componentAndroidType;
7072
#elif UNITY_IOS
7173
componentType = m_componentIOSType;
74+
#elif UNITY_WEBGL
75+
componentType = m_componentWebGLType;
76+
#elif UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX
77+
componentType = m_componentPCType;
7278
#else
7379
componentType = typeof(DefaultPaymentManager).FullName;
7480
#endif

0 commit comments

Comments
 (0)