本文整理汇总了C#中Browser.CallFunction方法的典型用法代码示例。如果您正苦于以下问题:C# Browser.CallFunction方法的具体用法?C# Browser.CallFunction怎么用?C# Browser.CallFunction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Browser
的用法示例。
在下文中一共展示了Browser.CallFunction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
void Start()
{
JSONObject configJSON = new JSONObject();
JSONObject j = new JSONObject();
JSONObject platforms = new JSONObject(JSONObject.Type.ARRAY);
string thisDirectory = Directory.GetCurrentDirectory();
bool platformDirectory = false;
browser = browserContainer.GetComponent<Browser>();
DirectoryInfo dir = new DirectoryInfo(thisDirectory + @"\Platforms");
try {
if (dir.Exists) {
platformDirectory = true;
} else {
dir.Create();
platformDirectory = true;
}
} catch (Exception e) {
platformDirectory = false;
Debug.Log(e);
}
if (platformDirectory) {
FileInfo[] info = dir.GetFiles("*.png");
platformTextures = new Texture2D[info.Length];
platformNames = new string[info.Length];
platformIdentities = new int[info.Length][];
configJSON.AddField("player", "Bloodyaugust");
configJSON.AddField("platforms", platforms);
int i = 0;
foreach (FileInfo f in info) {
j = new JSONObject();
WWW currentTexture = new WWW("file:///" + f);
platformTextures[i] = currentTexture.texture;
platformNames[i] = Path.GetFileNameWithoutExtension(f + "");
platformIdentities[i] = TextureToIdentity(platformTextures[i]);
platforms.Add(j);
j.AddField("name", platformNames[i]);
j.AddField("value", i.ToString());
Debug.Log(Path.GetFileNameWithoutExtension(f + ""));
i++;
}
browser.CallFunction("Messaging.trigger", "platforms", configJSON.ToString());
Debug.Log(configJSON.ToString());
}
}