[英]Set resolution of facebook canvas unity3d
I have uploaded my unity game on webserver and its working on facebook. 我已经在网络服务器上上传了我的统一游戏,并在Facebook上进行了工作。 but i have facebook canvas resolution problem.
但我有Facebook画布分辨率问题。 as my game is in portrait mode.
因为我的游戏是纵向模式。 Screen resolution is 400 x 600..
屏幕分辨率为400 x 600 ..
How do i set this resolution in my unity project. 如何在我的统一项目中设置此分辨率。 as facebook settings is not allowing me to set canvas width.
由于Facebook设置不允许我设置画布宽度。
We have method available : FB.Canvas.SetResolution(int width , int height , bool fullscreen, int prefferedRefreshRate , Params Fbscreen.Layout[] layoutparams) 我们有可用的方法: FB.Canvas.SetResolution(int width,int height,bool fullscreen,int prefferedRefreshRate,参数Fbscreen.Layout [] layoutparams)
i dnt knw which facebook layout parameter should i write. 我不知道我应该写哪个Facebook布局参数。
Help me guys.. 帮帮我..
Thanks for your help and support.. :) 感谢您的帮助和支持.. :)
Well i had a similar problem, if you need to set your game's resolution on Facebook Canvas through Unity's Web Player, you just need to: 好吧,我有一个类似的问题,如果您需要通过Unity的Web Player在Facebook Canvas上设置游戏的分辨率,则只需要:
Application.ExternalCall("IntegratedPluginCanvas.setResolution", width, height);
Getting a Web Player's game to work at an appropriate resolution on Facebook Canvas is a bit messy, specially if you have your own injected HTML on screen. 在Facebook Canvas上以适当的分辨率运行Web Player的游戏有点麻烦,特别是如果您在屏幕上拥有自己注入的HTML。 I find myself building the game at a default resolution, setting another fixed height on the game's configuration on facebook's development backoffice, and another resolution through the above method.
我发现自己以默认分辨率构建游戏,在Facebook的开发后台上为游戏的配置设置了另一个固定高度,并通过上述方法设置了另一个分辨率。
Anyway, try this one :) 无论如何,尝试这个:)
I solved my problem using below code which is given in sample example of Facebook : 我使用下面的代码示例Facebook中的示例给出了解决我的问题:
#region FB.Canvas.SetResolution example
public string Width = "800";
public string Height = "600";
public bool CenterHorizontal = true;
public bool CenterVertical = false;
public string Top = "10";
public string Left = "10";
public void CallCanvasSetResolution()
{
int width;
if (!Int32.TryParse(Width, out width))
{
width = 800;
}
int height;
if (!Int32.TryParse(Height, out height))
{
height = 600;
}
float top;
if (!float.TryParse(Top, out top))
{
top = 0.0f;
}
float left;
if (!float.TryParse(Left, out left))
{
left = 0.0f;
}
if (CenterHorizontal && CenterVertical)
{
FB.Canvas.SetResolution(width, height, false, 0, FBScreen.CenterVertical(), FBScreen.CenterHorizontal());
}
else if (CenterHorizontal)
{
FB.Canvas.SetResolution(width, height, false, 0, FBScreen.Top(top), FBScreen.CenterHorizontal());
}
else if (CenterVertical)
{
FB.Canvas.SetResolution(width, height, false, 0, FBScreen.CenterVertical(), FBScreen.Left(left));
}
else
{
FB.Canvas.SetResolution(width, height, false, 0, FBScreen.Top(top), FBScreen.Left(left));
}
}
#endregion
Hope it helps all of you.. Thanks.. 希望对您有帮助。.谢谢..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.