Exemple #1
0
    // Start is called before the first frame update
    void Start()
    {
        mSceneModule = NFRoot.Instance().GetPluginManager().FindModule <NFSceneModule>();
        GameObject xModelObject = mSceneModule.GetModelObject();

        ModelInput = xModelObject.GetComponent <NFModelInput>();
    }
Exemple #2
0
    public IEnumerator RequireModelTargetHttp(int tar, int level)
    {
        string url = "http://" + mNetModule.strGameServerIP + ":9001/model";

        url += "?target=" + tar.ToString() + "&level=" + level.ToString();
        string data = "";

        // StartCoroutine(SendModelRequest(url));
        yield break;
        var    resp = JSON.Parse(data);
        string msg  = resp["msg"].Value;

        byte[] temp = Convert.FromBase64String(msg);
        msg = Encoding.UTF8.GetString(temp);
        string raw = resp["sync_unit"]["raw"].Value;

        temp = Convert.FromBase64String(raw);
        raw  = Encoding.UTF8.GetString(temp);

        System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 当地时区
        long            timeStamp = (long)(DateTime.Now - startTime).TotalMilliseconds;                    // 相差秒数

        Debug.Log("receive msg " + timeStamp);
        // NFMsg.MsgBase xMsg = NFMsg.MsgBase.Parser.ParseFrom(System.Text.Encoding.Unicode.GetBytes(stream));
        // NFMsg.ReqAckModelTarget xData = NFMsg.ReqAckModelTarget.Parser.ParseFrom(xMsg.MsgData);
        // Debug.Log(xData.Msg.ToStringUtf8());
        // string[] msgs = xData.Msg.ToStringUtf8().Split(' ');
        string[]    msgs  = msg.Split(' ');
        List <long> times = new List <long>();

        times.Add(long.Parse(msgs[1]) - long.Parse(msgs[0]));
        times.Add(long.Parse(msgs[2]) - long.Parse(msgs[1]));
        times.Add(timeStamp - long.Parse(msgs[2]));
        // if (xData.SyncUnit.Raw == null)
        if (raw == null)
        {
            Debug.Log("model ack null");
        }
        GameObject     xModelObject = mSceneModule.GetModelObject();
        NFModelControl modelCtl     = xModelObject.GetComponent <NFModelControl>();
        // string raw = xData.SyncUnit.Raw.ToStringUtf8();
        // System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
        // stopwatch.Start(); //  开始监视代码运行时间

        DateTime beforDT = System.DateTime.Now;

        Debug.Log(String.Format("开始{0}ms.", beforDT.Millisecond));
        modelCtl.LoadTextureFromRaw(raw, ModelRawType.FORMATTED);
        // stopwatch.Stop(); //  停止监视
        // System.TimeSpan timespan = stopwatch.Elapsed;
        // double milliseconds = timespan.TotalMilliseconds;  //  总毫秒数
        DateTime afterDT = System.DateTime.Now;

        Debug.Log(String.Format("结束{0}ms.", afterDT));
        TimeSpan ts = afterDT.Subtract(beforDT);

        Debug.Log(String.Format("总共花费{0}ms.", ts.TotalMilliseconds));
        times.Add((long)ts.TotalMilliseconds);
        // Debug.Log("Recalculate Normals " + milliseconds);
        NFUIMain mainUI = mUIModule.GetUI <NFUIMain>();

        mainUI.SetMessage(0, "读取模型: " + times[0].ToString() + " ms");
        mainUI.SetMessage(1, "网格转换: " + times[1].ToString() + " ms");
        mainUI.SetMessage(2, "网络传输: " + times[2].ToString() + " ms");
        mainUI.SetMessage(3, "模型加载: " + times[3].ToString() + " ms");
    }
Exemple #3
0
    private void OnHoverSyncChanged(bool IsOn)
    {
        NFModelSync ModelSync = mSceneModule.GetModelObject().GetComponent <NFModelSync>();

        ModelSync.mHoverSyncOn = IsOn;
    }