notebook实装功能,galgame继续,一些bug修复
This commit is contained in:
@@ -6,6 +6,7 @@ using UnityEngine.EventSystems;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.Audio;
|
||||
using Bansonic;
|
||||
using Steamworks;
|
||||
|
||||
public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
{
|
||||
@@ -75,6 +76,13 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
public int depth;
|
||||
}
|
||||
|
||||
[Header("Steam Integration")]
|
||||
public Material steamMaterial;
|
||||
public Text steamUserNameText;
|
||||
public Text steamUserID64Text;
|
||||
public Text steamStatusText;
|
||||
public Image steamUserAvatarImage;
|
||||
|
||||
private UnityAction instantiateSettings;
|
||||
private UnityAction instantiateUserInfo;
|
||||
private UnityAction instantiateStore;
|
||||
@@ -164,6 +172,8 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
if (button_Music != null)
|
||||
button_Music.onClick.AddListener(ToggleMusicPicLocal);
|
||||
|
||||
UpdateSteamUserInfo();
|
||||
|
||||
var binder = BgmUiBinder.Instance != null ? BgmUiBinder.Instance : Object.FindAnyObjectByType<BgmUiBinder>();
|
||||
if (binder != null && musicPicRoot != null)
|
||||
{
|
||||
@@ -869,4 +879,74 @@ public class btmandtopController : MonoBehaviour, ICancelHandler
|
||||
}
|
||||
navSceneLoading = false;
|
||||
}
|
||||
|
||||
public void UpdateSteamUserInfo()
|
||||
{
|
||||
if (!SteamManager.Initialized)
|
||||
{
|
||||
Debug.LogWarning("[Steam] SteamManager not initialized.");
|
||||
if (steamStatusText != null)
|
||||
steamStatusText.text = "Unknown Server";
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
CSteamID steamID = SteamUser.GetSteamID();
|
||||
|
||||
if (steamUserNameText != null)
|
||||
steamUserNameText.text = SteamFriends.GetPersonaName();
|
||||
|
||||
if (steamUserID64Text != null)
|
||||
steamUserID64Text.text = "Uid : " + steamID.m_SteamID.ToString();
|
||||
|
||||
// Online status check
|
||||
EPersonaState state = SteamFriends.GetPersonaState();
|
||||
bool isOffline = (state == EPersonaState.k_EPersonaStateOffline);
|
||||
|
||||
if (steamStatusText != null)
|
||||
{
|
||||
steamStatusText.text = isOffline ? "Steam Offline" : "Steam Online";
|
||||
}
|
||||
|
||||
if (steamUserAvatarImage != null)
|
||||
{
|
||||
// Assign material if offline, otherwise set to null (default)
|
||||
steamUserAvatarImage.material = isOffline ? steamMaterial : null;
|
||||
|
||||
int iImage = SteamFriends.GetMediumFriendAvatar(steamID);
|
||||
if (iImage != -1)
|
||||
{
|
||||
uint width, height;
|
||||
if (SteamUtils.GetImageSize(iImage, out width, out height))
|
||||
{
|
||||
byte[] imageBuffer = new byte[width * height * 4];
|
||||
if (SteamUtils.GetImageRGBA(iImage, imageBuffer, (int)(width * height * 4)))
|
||||
{
|
||||
Texture2D texture = new Texture2D((int)width, (int)height, TextureFormat.RGBA32, false);
|
||||
texture.LoadRawTextureData(imageBuffer);
|
||||
texture.Apply();
|
||||
|
||||
// Flip the texture vertically because Steam returns it upside down
|
||||
Texture2D flipped = new Texture2D((int)width, (int)height, TextureFormat.RGBA32, false);
|
||||
for (int y = 0; y < (int)height; y++)
|
||||
{
|
||||
Color[] pixels = texture.GetPixels(0, y, (int)width, 1);
|
||||
flipped.SetPixels(0, (int)height - 1 - y, (int)width, 1, pixels);
|
||||
}
|
||||
flipped.Apply();
|
||||
|
||||
steamUserAvatarImage.sprite = Sprite.Create(flipped, new Rect(0, 0, width, height), new Vector2(0.5f, 0.5f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError("[Steam] Error updating steam info: " + e);
|
||||
if (steamStatusText != null)
|
||||
steamStatusText.text = "Unknown Server";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user