本文整理汇总了C#中JsonData.ToJSON方法的典型用法代码示例。如果您正苦于以下问题:C# JsonData.ToJSON方法的具体用法?C# JsonData.ToJSON怎么用?C# JsonData.ToJSON使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonData
的用法示例。
在下文中一共展示了JsonData.ToJSON方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleNetInput
// Parse the input sent from the client and use it to update the controls for the next simulation segment
public override void HandleNetInput(JsonData jsonData, ref Vector3 targetVel)
{
Debug.Log (jsonData.ToJSON ());
// Get movement
_myAvatar.sendSceneInfo = jsonData["send_scene_info"].ReadBool(false);
cacheVel = _myAvatar.moveSpeed * jsonData["vel"].ReadVector3(Vector3.zero);
targetVel = cacheVel;
cacheAngVel = _myAvatar.rotSpeed * jsonData["ang_vel"].ReadVector3(Vector3.zero);
if (jsonData["teleport_random"].ReadBool(false))
_myAvatar.TeleportToValidPosition();
_myAvatar.shouldCollectObjectInfo = jsonData["get_obj_data"].ReadBool(false);
List<string> relationships = new List<string>();
if (!jsonData["relationships"].ReadList(ref relationships))
{
string testStr = null;
if (jsonData["relationships"].ReadString(ref testStr) && testStr != null && testStr.ToUpper() == "ALL")
relationships.Add(testStr);
}
_myAvatar.relationshipsToRetrieve = relationships;
// Apply Magic
JsonData actionsList = jsonData["actions"];
if (actionsList != null) {
int actionsCount = actionsList.Count;
SemanticObject[] allObjects = UnityEngine.Object.FindObjectsOfType<SemanticObject>();
for (int i = 0; i < actionsCount; i++) {
JsonData action = actionsList [i];
string id = action ["id"].ReadString ();
Vector3 force = action ["force"].ReadVector3 ();
force = _myAvatar.transform.TransformDirection (force);
Vector3 torque = action ["torque"].ReadVector3 ();
torque = _myAvatar.transform.TransformDirection (torque);
foreach (SemanticObject o in allObjects) {
string idval = NetMessenger.colorUIDToString(o.gameObject.GetComponentInChildren<Renderer> ().material.GetColor ("_idval"));
if (idval == id) {
Rigidbody rb = o.gameObject.GetComponentInChildren<Rigidbody> ();
rb.AddForce (force);
rb.AddTorque (torque);
}
}
}
}
}
示例2: ParseJsonInfo
public static void ParseJsonInfo(string fileName)
{
string testConfigInfo = ReadConfigFile(fileName);
#if UNITY_EDITOR
// Read sample config if we have no config
if (testConfigInfo == null)
{
Debug.Log("Reading sample config");
const string configLoc = "Assets/Scripts/sample_config.txt";
TextAsset sampleConfig = UnityEditor.AssetDatabase.LoadAssetAtPath<TextAsset>(configLoc);
if (sampleConfig != null)
{
Debug.Log("Found sample config: " + sampleConfig.text);
testConfigInfo = sampleConfig.text;
}
}
#endif
if (testConfigInfo == null)
return;
_readJsonArgs = JsonMapper.ToObject(testConfigInfo);
if (_readJsonArgs!= null)
{
ReadLogLevel(_readJsonArgs["log_level"], ref logLevel);
ReadLogLevel(_readJsonArgs["stack_log_level"], ref stackLogLevel);
logFileLocation = _readJsonArgs["output_log_file"].ReadString(logFileLocation);
}
Debug.LogFormat("Completed reading configuration at {0}:\n{1}", fileName, _readJsonArgs.ToJSON());
}
示例3: sendMongoDBsearch
public static JsonData sendMongoDBsearch(JsonData jsonData)
{
Debug.Log("I am in Sending message!" + jsonData.ToJSON());
return myNetMessenger.SendAndReceiveMongoDB(jsonData);
}
示例4: SendAndReceiveMongoDB
public JsonData SendAndReceiveMongoDB(JsonData jsonData)
{
clientInfo.SendFrame(jsonData.ToJSON());
Debug.Log("Message info sent!");
//_lastMessage_info = clientInfo.ReceiveMessage();
TimeSpan timeout = TimeSpan.FromSeconds(30);
bool did_receive = false;
while(!did_receive)
did_receive = clientInfo.TryReceiveMultipartMessage(timeout, ref _lastMessage_info);
//if (clientInfo.TryReceiveMultipartMessage(ref _lastMessage_info)){
Debug.Log("Receive info: ");
string msgHeader = _lastMessage_info.First.ConvertToString();
JsonData jsonData_ = _lastMessage_info.ReadJson(out msgHeader);
Debug.Log("To Json: " + jsonData_);
return jsonData_;
//return CreateMsgJson("Noback");
}