Browse Source

web适配

master
azazaz123456 9 hours ago
parent
commit
ddda7d03d3
9 changed files with 70 additions and 11 deletions
  1. +1
    -0
      Assets/Resources/UI/UIMainMenu.prefab
  2. +5
    -0
      Assets/Scripts/Buy/IAPManager.cs
  3. +16
    -0
      Assets/Scripts/Data/GameConfig.cs
  4. +11
    -0
      Assets/Scripts/Data/GameConfig.cs.meta
  5. +8
    -0
      Assets/Scripts/Data/GameData.cs
  6. +9
    -1
      Assets/Scripts/Init.cs
  7. +6
    -0
      Assets/Scripts/UI/UIMainMenu.cs
  8. +1
    -1
      Assets/StreamingAssets/build_info
  9. +13
    -9
      ProjectSettings/ProjectSettings.asset

+ 1
- 0
Assets/Resources/UI/UIMainMenu.prefab View File

@@ -1396,6 +1396,7 @@ MonoBehaviour:
appleUserIdText: {fileID: 5200266615250658360}
DeleteAccountButton: {fileID: 1117439657247871432}
LogOutButton: {fileID: 2886384592295336126}
SettingButton: {fileID: 3980948398050332762}
--- !u!1 &6722503920034882643
GameObject:
m_ObjectHideFlags: 0


+ 5
- 0
Assets/Scripts/Buy/IAPManager.cs View File

@@ -31,6 +31,11 @@ public class IAPManager : MonoBehaviour, IDetailedStoreListener

async void Start()
{
if (GameConfig.platform!= RuntimePlatform.IPhonePlayer)
{
Debug.LogWarning("非 iOS 平台,无法初始化 IAP");
return;
}
await UnityServices.InitializeAsync(); // 初始化 UGS
var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
builder.AddProduct(subscriptionId, ProductType.Subscription);


+ 16
- 0
Assets/Scripts/Data/GameConfig.cs View File

@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameConfig
{
#if UNITY_ANDROID
public static RuntimePlatform platform = RuntimePlatform.Android;
#elif UNITY_IPHONE
public static RuntimePlatform platform = RuntimePlatform.IPhonePlayer;
#else
public static RuntimePlatform platform = RuntimePlatform.WebGLPlayer;
#endif


}

+ 11
- 0
Assets/Scripts/Data/GameConfig.cs.meta View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f8d8ad7c45ecf8845af206bbddf3dc5d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

+ 8
- 0
Assets/Scripts/Data/GameData.cs View File

@@ -4,6 +4,7 @@ using UnityEngine;

public class GameData : MonoBehaviour
{

public static GameData Instance { get; private set; }

//public string username = "游客";
@@ -25,3 +26,10 @@ public class GameData : MonoBehaviour
DontDestroyOnLoad(gameObject); // 场景切换不销毁
}
}

public enum GameDataType
{
Username,
AppleUserId,
IsYouke
}

+ 9
- 1
Assets/Scripts/Init.cs View File

@@ -7,7 +7,15 @@ public class Init : MonoBehaviour
// Start is called before the first frame update
void Start()
{
UIManager.Instance.OpenUI<UILogin>();
if (GameConfig.platform == RuntimePlatform.WebGLPlayer)
{
UIManager.Instance.OpenUI<UIMainMenu>();
}
else
{
UIManager.Instance.OpenUI<UILogin>();
}
}

// Update is called once per frame


+ 6
- 0
Assets/Scripts/UI/UIMainMenu.cs View File

@@ -14,11 +14,17 @@ public class UIMainMenu : UIBase
[SerializeField]
Button LogOutButton;

[SerializeField]
GameObject SettingButton;

public override void OnOpen(params object[] args)
{
DeleteAccountButton.onClick.AddListener(ClickDeleteAccountButton);
LogOutButton.onClick.AddListener(ClickLogOutButton);
if (GameConfig.platform == RuntimePlatform.WebGLPlayer)
{
SettingButton.SetActive(false);
}
}




+ 1
- 1
Assets/StreamingAssets/build_info View File

@@ -1 +1 @@
Build from CHINAMI-5S19PK6 at 2025/8/5 17:18:43
Build from CHINAMI-5S19PK6 at 2025/8/7 17:29:08

+ 13
- 9
ProjectSettings/ProjectSettings.asset View File

@@ -44,10 +44,10 @@ PlayerSettings:
m_HolographicTrackingLossScreen: {fileID: 0}
defaultScreenWidth: 1920
defaultScreenHeight: 1080
defaultScreenWidthWeb: 960
defaultScreenHeightWeb: 600
defaultScreenWidthWeb: 480
defaultScreenHeightWeb: 854
m_StereoRenderingPath: 0
m_ActiveColorSpace: 1
m_ActiveColorSpace: 0
m_MTRendering: 1
mipStripping: 0
numberOfMipsStripped: 0
@@ -155,15 +155,16 @@ PlayerSettings:
androidSupportedAspectRatio: 1
androidMaxAspectRatio: 2.1
applicationIdentifier:
Android: com.sange.MosquitoKillerOutdoor
iPhone: com.sange.quwen
buildNumber:
Standalone: 0
iPhone: 0
tvOS: 0
overrideDefaultApplicationIdentifier: 1
overrideDefaultApplicationIdentifier: 0
AndroidBundleVersionCode: 1
AndroidMinSdkVersion: 22
AndroidTargetSdkVersion: 0
AndroidTargetSdkVersion: 28
AndroidPreferredInstallLocation: 1
aotOptions:
stripEngineCode: 1
@@ -245,7 +246,7 @@ PlayerSettings:
useCustomBaseGradleTemplate: 0
useCustomGradlePropertiesTemplate: 0
useCustomProguardFile: 0
AndroidTargetArchitectures: 1
AndroidTargetArchitectures: 3
AndroidTargetDevices: 0
AndroidSplashScreenScale: 0
androidSplashScreen: {fileID: 0}
@@ -552,6 +553,8 @@ PlayerSettings:
m_EncodingQuality: 1
- m_BuildTarget: tvOS
m_EncodingQuality: 1
- m_BuildTarget: WebGL
m_EncodingQuality: 1
m_BuildTargetGroupLightmapSettings: []
m_BuildTargetNormalMapEncoding:
- m_BuildTarget: Android
@@ -803,7 +806,7 @@ PlayerSettings:
webGLDebugSymbols: 0
webGLEmscriptenArgs:
webGLModulesDirectory:
webGLTemplate: APPLICATION:Default
webGLTemplate: APPLICATION:Minimal
webGLAnalyzeBuildSize: 0
webGLUseEmbeddedResources: 0
webGLCompressionFormat: 1
@@ -815,7 +818,8 @@ PlayerSettings:
scriptingDefineSymbols: {}
additionalCompilerArguments: {}
platformArchitecture: {}
scriptingBackend: {}
scriptingBackend:
Android: 1
il2cppCompilerConfiguration: {}
managedStrippingLevel:
EmbeddedLinux: 1
@@ -836,7 +840,7 @@ PlayerSettings:
allowUnsafeCode: 0
useDeterministicCompilation: 1
enableRoslynAnalyzers: 1
selectedPlatform: 3
selectedPlatform: 4
additionalIl2CppArgs:
scriptingRuntimeVersion: 1
gcIncremental: 1


Loading…
Cancel
Save