当前位置: 首页>>代码示例>>C#>>正文


C# JsonData.ToJSON方法代码示例

本文整理汇总了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);
                 }
             }
         }
     }
 }
开发者ID:dicarlolab,项目名称:ThreeDWorld,代码行数:43,代码来源:InputModule.cs

示例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());
 }
开发者ID:dicarlolab,项目名称:ThreeDWorld,代码行数:28,代码来源:SimulationManager.cs

示例3: sendMongoDBsearch

 public static JsonData sendMongoDBsearch(JsonData jsonData)
 {
     Debug.Log("I am in Sending message!" + jsonData.ToJSON());
         return myNetMessenger.SendAndReceiveMongoDB(jsonData);
 }
开发者ID:dicarlolab,项目名称:ThreeDWorld,代码行数:5,代码来源:SimulationManager.cs

示例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");
    }
开发者ID:dicarlolab,项目名称:ThreeDWorld,代码行数:18,代码来源:NetMessenger.cs


注:本文中的JsonData.ToJSON方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。