当我关闭游戏我想不和谐丰富的存在清除,但它仍然显示我在玩游戏,这是我的不和谐控制器:
using Discord;
using UnityEngine;
using UnityEngine.SceneManagement;
public class DiscordController : MonoBehaviour
{
public long applicationID;
[Space]
public string details = "Walking around the world";
public string state = "Current velocity: ";
[Space]
public string largeImage = "game_logo";
public string largeText = "Discord Tutorial";
private long time;
private static bool instanceExists;
public Discord.Discord discord;
Scene scene;
void Awake()
{
// Transition the GameObject between scenes, destroy any duplicates
if (!instanceExists)
{
instanceExists = true;
DontDestroyOnLoad(gameObject);
}
else if (FindObjectsOfType(GetType()).Length > 1)
{
Destroy(gameObject);
}
}
void Start()
{
// Log in with the Application ID
discord = new Discord.Discord(applicationID, (System.UInt64)Discord.CreateFlags.NoRequireDiscord);
time = System.DateTimeOffset.Now.ToUnixTimeMilliseconds();
UpdateStatus();
}
void Update()
{
scene = SceneManager.GetActiveScene();
// Destroy the GameObject if Discord isn't running
try
{
discord.RunCallbacks();
}
catch
{
Destroy(gameObject);
}
}
void LateUpdate()
{
UpdateStatus();
}
void UpdateStatus()
{
// Update Status every frame
try
{
var activityManager = discord.GetActivityManager();
var activity = new Discord.Activity
{
Details = details,
State = state + scene.name,
Assets =
{
LargeImage = largeImage,
LargeText = largeText
},
Timestamps =
{
Start = time
}
};
activityManager.UpdateActivity(activity, (res) =>
{
if (res != Discord.Result.Ok) Debug.LogWarning("Failed connecting to Discord!");
});
}
catch
{
// If updating the status fails, Destroy the GameObject
Destroy(gameObject);
}
}
}
在我离开游戏后,它仍然显示我在玩,我在youtube上找不到任何关于它的东西请帮助我解决这个问题,我已经尝试过自己,但我无法修复它Discord Image
1条答案
按热度按时间5lhxktic1#
您可以使用ActivityManager中的
activityManager.ClearActivity()
。此方法将通过回调返回Discord.Result示例:
有关此主题的更多信息,请单击此处。