fix:1、H5方案改为我们自己的sdk,跳转电商也是。2、同步部分ios的优化
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ChillConnect
|
||||
{
|
||||
public class AlphaController : MonoBehaviour
|
||||
{
|
||||
private AndroidJavaObject currentActivity;
|
||||
private bool isInitialized = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
// 只在 Android 平台初始化
|
||||
if (Application.platform == RuntimePlatform.Android)
|
||||
{
|
||||
InitializeAndroidBridge();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeAndroidBridge()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
|
||||
{
|
||||
currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
|
||||
isInitialized = true;
|
||||
Debug.Log("AlphaController: Android bridge initialized successfully");
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError("AlphaController: Failed to initialize Android bridge - " + e.Message);
|
||||
isInitialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置 Unity Player 透明度
|
||||
/// </summary>
|
||||
/// <param name="alpha">0.0 全透明, 1.0 不透明</param>
|
||||
public void SetPlayerAlpha(float alpha)
|
||||
{
|
||||
if (!isInitialized)
|
||||
{
|
||||
Debug.LogWarning("AlphaController: Not initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
// 限制透明度范围在 0-1 之间
|
||||
alpha = Mathf.Clamp01(alpha);
|
||||
currentActivity.Call("setPlayerAlpha", alpha);
|
||||
Debug.Log($"AlphaController: Set alpha to {alpha}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf7c461dccc24a89a0a3d1654c65bf0a
|
||||
timeCreated: 1784614395
|
||||
Reference in New Issue
Block a user