新Unity项目移植祖传代码(自用)

1.stringformat.cs脚本为字符串处理集。 2.datacenter.cs数据中心。 2.databinding.cs为数据变更的委托,对应进行刷新结合datacenter使用。 3.textModifier.cs为特殊文本的显示设置。 3.jsonobject.cs为字典类型的json序列化库。(可用litjson替换) 4.通信可以使用js通信,webrequest通信,websocket通信(长连接),besthttp通信,(注意https,post添加文件头等问题)。

其他问题: worn: The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. <警告>

移除camera的audiolistener 移除声音组件

RectTransform的父级通过父级属性设置。考虑改用SetParent方法,将worldPositionStays参数设置为false。这将保留局部方向和比例,而不是世界方向和比例,这可以防止常见的UI缩放问题。

pip(官网下载) pyinstaller (github) (python setup.py install) pyinstaller -F xxx.py

//public void BestHttpPost(string url, string jsonParam)
    //{
          
   
    //    HTTPRequest request = new HTTPRequest(new Uri(url), HTTPMethods.Post, OnRequestFinished);
    //    request.SetHeader("Content-Type", "application/json;charset=utf-8");
    //    request.SetHeader("authorization", "Bearer " + "Gtoken");
    //    request.RawData = Encoding.UTF8.GetBytes(jsonParam);
    //    request.Send();
    //}
    //void OnRequestFinished(HTTPRequest request, HTTPResponse response)
    //{
          
   
    //    Debug.Log(response.StatusCode);
    //    Debug.Log(response.Message);
    //    Debug.Log(response.IsSuccess);
    //    DealRequest(response.DataAsText);
    //}
using LitJson;
using UnityEngine;

public class TestJson : MonoBehaviour
{
          
   
    private void Start()
    {
          
   
        JsonData data = new JsonData();
        data["name"] = "peiandsky";
        data["age"] = "28";
        data["sex"] = "maie";
        data["info"] = new JsonData();
        data["info"]["n1"] = "123";
        data["info"]["n2"] = "234";
        string json1 = data.ToJson();//obj--->string
        Debug.Log(json1);
        JsonData data2 = JsonMapper.ToObject(json1);//string--->obj
        Debug.Log("-------------"+data2["info"]["n1"]);
        Debug.Log("++++++++++++++"+data2["sex"].IsObject);
        //写数组
        JsonData jd=new JsonData();
        jd["data"] = new JsonData();
        jd["data"].SetJsonType(JsonType.Array);
        JsonData temp = new JsonData();
        temp["id"] = "id";
        jd["data"].Add(0);
        jd["data"].Add(1);
        jd["data"][0] = temp;
        jd["data"][1] = temp;
		//读数组
		JsonData json= JsonMapper.ToObject(jd.ToJson());
		for (int i = 0; i < json["data"].length; i++)//如果没有length试试Count
		{
          
   
    		Console.WriteLine ("Id: {0}", json["data"][i]["id"]);
		}
    }
}
经验分享 程序员 微信小程序 职场和发展