Skip to content

Commit 233ad58

Browse files
committed
fix(payment): 将 macOS 从 PC 平台独立为单独的支付配置
macOS 可走 Mac App Store 使用 Apple 支付,与 iOS 同属 Apple 生态, 不应与 Windows/Linux 归为同一 PC 配置。默认使用 ApplePaymentManager, Inspector 新增 macOS 平台独立下拉框。
1 parent 702efd1 commit 233ad58

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

Editor/PaymentComponentInspector.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public sealed class PaymentComponentInspector : ComponentTypeComponentInspector
2222
private GUIContent m_componentAndroidTypeGUIContent = new GUIContent("Android平台支付组件");
2323
private GUIContent m_componentIOSTypeGUIContent = new GUIContent("iOS平台支付组件");
2424
private GUIContent m_componentWebGLTypeGUIContent = new GUIContent("WebGL平台支付组件");
25-
private GUIContent m_componentPCTypeGUIContent = new GUIContent("PC平台支付组件");
25+
private GUIContent m_componentPCTypeGUIContent = new GUIContent("PC平台支付组件 (Windows/Linux)");
26+
private GUIContent m_componentMacTypeGUIContent = new GUIContent("macOS平台支付组件");
2627

2728
private SerializedProperty ComponentAndroidType = null;
2829
private string[] ComponentAndroidTypeNames = null;
@@ -40,6 +41,10 @@ public sealed class PaymentComponentInspector : ComponentTypeComponentInspector
4041
private string[] ComponentPCTypeNames = null;
4142
private int ComponentPCTypeNameIndex = 0;
4243

44+
private SerializedProperty ComponentMacType = null;
45+
private string[] ComponentMacTypeNames = null;
46+
private int ComponentMacTypeNameIndex = 0;
47+
4348
public override void OnInspectorGUI()
4449
{
4550
base.OnInspectorGUI();
@@ -79,6 +84,14 @@ public override void OnInspectorGUI()
7984
ComponentPCTypeNameIndex = componentPCTypeNameIndex;
8085
ComponentPCType.stringValue = componentPCTypeNameIndex <= 0 ? null : ComponentPCTypeNames[componentPCTypeNameIndex];
8186
}
87+
88+
EditorGUILayout.LabelField(m_componentMacTypeGUIContent);
89+
int componentMacTypeNameIndex = EditorGUILayout.Popup("Component Mac Type", ComponentMacTypeNameIndex, ComponentMacTypeNames);
90+
if (componentMacTypeNameIndex != ComponentMacTypeNameIndex)
91+
{
92+
ComponentMacTypeNameIndex = componentMacTypeNameIndex;
93+
ComponentMacType.stringValue = componentMacTypeNameIndex <= 0 ? null : ComponentMacTypeNames[componentMacTypeNameIndex];
94+
}
8295
}
8396
EditorGUI.EndDisabledGroup();
8497

@@ -94,10 +107,12 @@ protected override void Enable()
94107
ComponentIOSType = serializedObject.FindProperty("m_componentIOSType");
95108
ComponentWebGLType = serializedObject.FindProperty("m_componentWebGLType");
96109
ComponentPCType = serializedObject.FindProperty("m_componentPCType");
110+
ComponentMacType = serializedObject.FindProperty("m_componentMacType");
97111
RefreshTypeNames(ComponentAndroidType, ref ComponentAndroidTypeNames, ref ComponentAndroidTypeNameIndex, typeof(IPaymentManager));
98112
RefreshTypeNames(ComponentIOSType, ref ComponentIOSTypeNames, ref ComponentIOSTypeNameIndex, typeof(IPaymentManager));
99113
RefreshTypeNames(ComponentWebGLType, ref ComponentWebGLTypeNames, ref ComponentWebGLTypeNameIndex, typeof(IPaymentManager));
100114
RefreshTypeNames(ComponentPCType, ref ComponentPCTypeNames, ref ComponentPCTypeNameIndex, typeof(IPaymentManager));
115+
RefreshTypeNames(ComponentMacType, ref ComponentMacTypeNames, ref ComponentMacTypeNameIndex, typeof(IPaymentManager));
101116
}
102117

103118
protected override void RefreshTypeNames()

Runtime/PaymentComponent.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class PaymentComponent : GameFrameworkComponent
2525
[SerializeField] private string m_componentIOSType = "GameFrameX.Payment.Apple.Runtime.ApplePaymentManager";
2626
[SerializeField] private string m_componentWebGLType = "GameFrameX.Payment.WebGL.Runtime.WebGLPaymentManager";
2727
[SerializeField] private string m_componentPCType = "GameFrameX.Payment.PC.Runtime.PCPaymentManager";
28+
[SerializeField] private string m_componentMacType = "GameFrameX.Payment.Apple.Runtime.ApplePaymentManager";
2829

2930
/// <summary>
3031
/// 购买成功事件
@@ -73,8 +74,10 @@ protected override void Awake()
7374
componentType = m_componentIOSType;
7475
#elif UNITY_WEBGL
7576
componentType = m_componentWebGLType;
76-
#elif UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX
77+
#elif UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX
7778
componentType = m_componentPCType;
79+
#elif UNITY_STANDALONE_OSX
80+
componentType = m_componentMacType;
7881
#else
7982
componentType = typeof(DefaultPaymentManager).FullName;
8083
#endif

0 commit comments

Comments
 (0)