这是我的第一个ASP.NET应用程序,我在将服务器端Bitmap对象传递给JavaScript客户端时遇到问题.我正在使用SignalR连接服务器和客户端.
我已经尝试过几件事情,并希望对于拥有ASP.NET经验的人来说这很容易.
这是我的服务器端C#:
public void ScreenShot()
{
Rectangle bounds = this.Bounds;
using (Image bitmap = new Bitmap(bounds.Width, bounds.Height))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
}
Clients.Caller.updateImage(bitmap);
}
}
Run Code Online (Sandbox Code Playgroud)
在客户端,我想获取位图并显示它:
hubproxy.client.updateImage = function (image) {
var img = document.createElement("img");
img.src = image;
document.body.appendChild(img);
};
Run Code Online (Sandbox Code Playgroud)
我必须将其转换为JSON对象吗?如果我这样做,如何将其恢复到客户端的图像?
在此先感谢您的帮助.
继承还是比较新的,所以我需要一些帮助.目前,我有一项任务是创建一个使用3武器继承的基本游戏.我的基类:
public class Weapons : MonoBehaviour
{
public int rateOfFire;
public string myName;
public Weapons(string Name)
{
myName = Name;
}
}
Run Code Online (Sandbox Code Playgroud)
其中一个子课程:
public class Rifle : Weapons
{
public Rifle(string Name)
: base(Name)
{
myName = Name;
rateOfFire = 5;
}
}
Run Code Online (Sandbox Code Playgroud)
我的第一个问题是,如果我做得对吗?
我的第二个问题是如何将这些实例化为我的Unity场景?我写了一个切换武器的方法,这是我的播放器脚本上的一个数组,所以我会在这里插入一个实例化的行还是创建另一个方法?缺少一些线条,但这是正确的:
public GameObject[] weapons;
public int currentweapon = 0;
private int invweap;
void Start()
{
//Managing weapons
invweap = weapons.Length;
SwitchWeapon(currentweapon);
}
void SwitchWeapon(int index)
{
for (int i = 0; i<invweap;i++)
{
if (i == …Run Code Online (Sandbox Code Playgroud)