我目前正在将Steamworks.net与Unity3d和C#结合使用。我要做的是获取Steam用户ID(在这种情况下为我自己的ID),然后执行一个函数。
这是我到目前为止的内容:
private static float berdyevID = 76561198040013516;
private static float steamID;
void Start() {
if(SteamManager.Initialized) {
string name = SteamFriends.GetPersonaName();
// get steam user id
steamID = Steamworks.SteamUser.GetSteamID();
// see if it matches
if (berdyevID == steamID) {
Debug.Log ("Steam ID did match");
} else {
Debug.Log ("Steam ID did not match");
}
}
}
Run Code Online (Sandbox Code Playgroud)
我从Unity收到一个错误,指出:
无法隐式转换类型Steamworks.CSteamID' tofloat'。存在显式转换(您是否缺少演员表?)
这让我感到困惑。我尝试在Google上进行研究,以找到可能的解决方法,但找不到任何东西。有人可以帮忙吗?
编辑:
我试过了,但是没有用:
private static ulong berdyevID = 76561198040013516;
private static ulong steamID;
void Start() {
if(SteamManager.Initialized) { …Run Code Online (Sandbox Code Playgroud) 需要帮助将JS转换为C#.
原文:
var target : GameObject;
var fadeDuration : float = 3.0;
function Update(){
if (target.GetComponent.<Renderer>().material.color.a > 0)
target.GetComponent.<Renderer>().material.color.a -= Time.deltaTime/fadeDuration;
}
Run Code Online (Sandbox Code Playgroud)
翻译的C#脚本:
using UnityEngine;
using System.Collections;
public class FadeOutDeadBody : MonoBehaviour {
GameObject target;
float fadeDuration = 3.0f;
void Update (){
if (target.GetComponent.<Renderer>().material.color.a > 0)
target.GetComponent.<Renderer>().material.color.a -= Time.deltaTime/fadeDuration;
}
}
Run Code Online (Sandbox Code Playgroud)
我收到来自Unity3d的错误说:
folder/FadeOutDeadBody.cs(9,29):错误CS1525:意外的符号
<', expecting标识符'
任何想法如何解决这个问题?
我有一个总点数的浮点数,它由计时器自动增加,但在总点数达到一定数量后,它似乎不再增加。我没有设置任何限制,所以我不确定为什么会发生这种情况。
因此,totalPoints 在达到“2097152”值时停止增加。
这是我的代码的一部分:
public float totalPoins;
void AccumulatePoints()
{
timer += Time.deltaTime * miningPowerValue;
if (timer > 1f)
{
totalPoints += someValue;
timer = 0;
}
}
Run Code Online (Sandbox Code Playgroud)
所以基本上它会根据挖矿PowerValue来累积积分。如果较低,积累速度会较慢,较高则积累速度较快。请帮忙。我很困惑。